0

I'm trying to write the content of a page on my server to a variable using file_get_contents:

$lnk = "https://www.example.com/test%20file.php";
$otpt = file_get_contents($lnk);

The full URL is needed because I need the PHP output of the page and not the PHP script itself.

When running the above code I get this warning: failed to open stream: HTTP request failed! No other information, e. g. HTML error code, is provided. allow_url_fopen is enabled on the server. error_reporting(E_ALL) doesn't show any more information. The only thing which seems mentionable to me is that the file_get_contents request takes much too long (up to 30 secs) for the ~57 KB file I'm currently testing on.

I checked the Reference - What does this error mean in PHP?, but to no avail. I really have no idea what this message means since any further specification by PHP is missing. Any help would be very much appreciated.

Thanks in advance!

bear87
  • 83
  • 1
  • 11
  • Does this answer your question? [PHP ini file\_get\_contents external url](https://stackoverflow.com/questions/3488425/php-ini-file-get-contents-external-url) – Salim Ibrohimi Jun 27 '20 at 13:14
  • @Salim Ibrogimov: I tried the cURL script presented there. It resulted in the page keeping loading and loading without an end. I only see a blank page. I let it run for roughly five minutes without any results, it justs keeps loading ... – bear87 Jun 27 '20 at 13:59
  • What's in file.php? – Salim Ibrohimi Jun 27 '20 at 14:06
  • @Salim Ibrogimov: Several HTML tables with data from a MySQL database. – bear87 Jun 27 '20 at 14:09
  • Do you print it and set appropriate HTTP header? – Salim Ibrohimi Jun 27 '20 at 14:14
  • @Salim Ibrogimov: I'm not sure what you mean by "Do you print it". HTTP headers in file.php are set as follows: Accept, Accept-Encoding, Accept-Language, Connection, DNT, Host, User-Agent. I'm not transmitting any HTTP headers with the cURL script though. – bear87 Jun 27 '20 at 14:29

0 Answers0