file_get_contents won't work with target of localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
coldwinds
Forum Newbie
Posts: 5
Joined: Sat Jun 21, 2008 2:26 pm

file_get_contents won't work with target of localhost

Post 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.
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: file_get_contents won't work with target of localhost

Post 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.
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: file_get_contents won't work with target of localhost

Post 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
Post Reply