curl_setopt doesnt work with url as a variable

2019-08-12 15:48发布

问题:

If i go like this - it works:

curl_setopt($ch, CURLOPT_URL, "http://www.facebook.com/pages/Muzikos-R%C5%ABsys/192813414094112?sk=events");

But if i try this

$url = "http://www.facebook.com/pages/Muzikos-R%C5%ABsys/192813414094112?sk=events";
curl_setopt($ch, CURLOPT_URL, $url);

it returns me a blank page;

Any ideas? Cant find the answer so far...

回答1:

Try this code:

$url = "http://www.facebook.com/pages/Muzikos-R%C5%ABsys/192813414094112?sk=events";
$ch  = curl_init($url);
$res = curl_exec($ch);