abdfahim Posted June 13, 2010 Share Posted June 13, 2010 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, Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 13, 2010 Share Posted June 13, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/#findComment-1071369 Share on other sites More sharing options...
abdfahim Posted June 13, 2010 Author Share Posted June 13, 2010 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.'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/#findComment-1071371 Share on other sites More sharing options...
abdfahim Posted June 13, 2010 Author Share Posted June 13, 2010 guys, does that(the warning posted in the last reply) mean that there is something needs to be changed in php.ini or something that is not in my hand (rather, hosting provider's hand)? Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/#findComment-1071376 Share on other sites More sharing options...
I Am Java Posted June 13, 2010 Share Posted June 13, 2010 More than likely. Not many hosts allow you to include files from outside sources. Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/#findComment-1071378 Share on other sites More sharing options...
abdfahim Posted June 13, 2010 Author Share Posted June 13, 2010 More than likely. Not many hosts allow you to include files from outside sources. But in that case, why the server is showing the following (Reply#1)? file_get_contents: Enabled allow_url_fopen: Enabled Quote Link to comment https://forums.phpfreaks.com/topic/204629-problem-with-file_get_contents/#findComment-1071380 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.