Jump to content

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.');

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.