file_get_contents() Error

When i try to use the file_get_contents() function to get the content of a URL,
i get the following error:

Warning: file_get_contents($http) [function.file_get_contents]: failed to open stream: No such file or directory in /url on line 18

What could be the cause of such error and the solution.
I’m using a shared server, how do i enable the function locally on my
own hosting account.

Read the error again, it means the path you specified to the file doesn’t exist. Lets say i want to open file.txt in some_folder

Working path: ./some_folder/file.txt
Non Working: ./file.txt

im actually trying to open a web url specified fully with http://www

Regardless of the path the same logic applys, can you access the link by putting it in the address bar?

Run phpinfo() and check the value for Registered PHP Streams in the topmost table. In order to be able to load urls the value ‘http’ should be there (among others). If not, you might need to ask your host to enable it. If that is not successful, you could be able to do the same with curl functions, however more complicated - that is, if your host provides curl as well.

  • Show us the complete code you have so far.
  • Check the URL outside PHP (browser) if you see it loads content
  • See the manual page for the function file_get_contents()

http is there.