PHP: file_get_contents(), localhost and Windows Vista
September 8th, 2009 by Elchie
Just try this code with PHP:
echo file_get_contents(”http://localhost/some/path/xyz.php”);
If you work on a Linux-system or a Windows-system other than Windows Vista this will work fine, but on vista, the call will hang - after some time you will get just a message “Host refused the connection”; calling the url in a browser works fine.
It’s a bug - just change localhost to 127.0.0.1 and it will work, this is a Windows Vista-only problem, but it won’t be fixed in PHP (seeĀ http://bugs.php.net/bug.php?id=40881).
By the way: Replacing localhost by the computers host name won’t work - you have to use localhost.
Posted in Uncategorized