I have the following PHP code:
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $URL);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec ($curl);
echo $html;
whith following result:
OK for a $URL like "http://www.google.com"
KO for a $URL like "http://localhost/index.html", and returning bool(false) when I do a var_dump
and this even though the browser can display http://localhost/index.html with no problem. I am running a xampp apache server on the localhost.
I cannot figure out what the problem is. Any help would be much appreciated.
You should make sure that your Apache listens on the correct interfaces. I had this problem once on a Vist machine: Apache (XAMP) was listening only on IPv4, but on Vista "localhost" resolves to an IPv6 address by default.
To disable the IPv6 address, edit you %system32%\drivers\etc\hosts file and remove the ::1 line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With