Jump to content

problem with file_get_contents


abdfahim

Recommended Posts

Hi experts,

 

I have some problem with file_get_contents.

 

In my server, I have that function enabled. I have checked the following 2 commands and they returned true (enabled), but unable to read any sites (for example www.google.com)

 

echo file_get_contents(__FILE__) ? 'file_get_contents: Enabled ' : 'file_get_contents: Disabled';
echo ini_get('allow_url_fopen') ? "allow_url_fopen: Enabled " : "allow_url_fopen: Disabled";
file_get_contents('http://www.google.com') or die('Unable to access DSE prices.');

 

OUTPUT

file_get_contents: Enabled 
allow_url_fopen: Enabled
Unable to access DSE prices.

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/
Share on other sites

Enable full php error_reporting/display_errors to see if php is reporting the reason why the file_get_contents() is failing. Add the following two lines immediately after the line with your first opening <?php tag -

 

ini_set("display_errors", "1");
error_reporting(E_ALL);

Enable full php error_reporting/display_errors to see if php is reporting the reason why the file_get_contents() is failing. Add the following two lines immediately after the line with your first opening <?php tag -

 

ini_set("display_errors", "1");
error_reporting(E_ALL);

 

Hi,

 

I get the following error, though  phpinfo.php file has only following codes

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/vol1/byethost17.com/b17_798655/iamabd.com/htdocs/phpinfo.php  on line 7

Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/vol1/byethost17.com/b17_798655/iamabd.com/htdocs/phpinfo.php on line 7

 

phpinfo.php

<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
echo file_get_contents(__FILE__) ? 'file_get_contents: Enabled ' : 'file_get_contents: Disabled';
echo ini_get('allow_url_fopen') ? "allow_url_fopen: Enabled " : "allow_url_fopen: Disabled";

file_get_contents('http://www.google.com') or die('Unable to access DSE prices.');

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.