-1

I have a problem with the file_get_contents function. One week ago every thing was perfect. Today when i call via file_get_contents a file which is on the same HOST/Server, it fails. The result is, that i get the startpage of google.de.

Then i tried to call the same full-url ( http://www.mydomains.com/script/test.php ) in console via curl. The result is a empty string. But files on other servers/hosts i can call without problems. With file_get_contents and with console->curl.

Any idea, how to solve this problem?

mr_app
  • 1,292
  • 2
  • 16
  • 37
  • sounds like network related problems. ask your admin before change anything in the code – hek2mgl Jun 13 '13 at 15:15
  • i have no admin. The project is on a vServer – mr_app Jun 13 '13 at 15:16
  • actual response for the url is a 404 – Orangepill Jun 13 '13 at 15:16
  • :) ok, then you are the admin. I just meant that if the application worked last week as are saying, then it is a network problem (likely dns) .. check this – hek2mgl Jun 13 '13 at 15:17
  • 2
    Try opening the file in your browser. If the site doesn't exist, it's DNS. If it loads just fine, either the user agent for Curl is being blocked, or the port is being blocked. –  Jun 13 '13 at 15:20
  • So far you have only written that something does not work, however you have not specified the problem, so this requires troube-shooting first. Find out how you can obtain more error messages from PHP, it's docuemnted in the PHP manual. Then edit your question and add the additional error messages you ***must obtain first*** - if `file_get_contents` fails ***there are notices, warnings and errors reported by PHP*** and those are ***for sure***. It's only you standing in the way to obtain them. Obtain them now, edit your question. – hakre Jun 18 '13 at 15:09

1 Answers1

2

Chances are your firewall rules are preventing you from call your own URL but you can use "real" paths with file_get_contents:

http://php.net/manual/en/function.file-get-contents.php

$file = file_get_contents('/path/to/file/people.txt', true);

Michael Sole
  • 124
  • 4