Page 1 of 1

file_get_contents won't work with target of localhost

Posted: Mon Aug 25, 2008 10:28 pm
by coldwinds
When I request a localhost page via file_get_content(),I got this warning while other http target it's ok, like http://google.com, anyone could help? thanks a bunch:)

Warning: file_get_contents(http://127.0.0.1/t/api/uc.php?s=UIEIRQb ... SR0DN9Q%3D) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in D:\xampplite\htdocs\t\login.php on line 162

both 127.0.0.1 and localhost is malfunctioned.

Plus: the local url is working fine when I check it with my firefox.

Re: file_get_contents won't work with target of localhost

Posted: Tue Aug 26, 2008 2:18 am
by panic!
I just tried

Code: Select all

 
$hehe=file_get_contents('http://127.0.0.1');
 
print $hehe;
 
 

and with localhost too and they both worked for me!

So it's most likely a problem with your specific set up, rather than a general PHP problem.

Re: file_get_contents won't work with target of localhost

Posted: Tue Aug 26, 2008 2:34 am
by Ziq
http://127.0.0.1/t/api/uc.php?s=UIEIRQb ... SR0DN9Q%3D this page not exist or it send header

Code: Select all

 
404 Not Found
 
Attentively see a code uc.php