php file_get_contents returning false ...


I am stuck with the issue.

Trying to retrieve rss from my url to a sub path, I am getting false. But the rss appears when retrieving it from the browser.

Here is my code. Could someone please advice me on what I should do ?

    $this->feed = '';
    print_r($this->feed);echo PHP_EOL;
    // die('getting feed url');
    $feed = file_get_contents($this->feed);

What is your php.ini configuration? In special the allow_url_fopen value.

Here is some code in PHP to get the content of an external URL, but using the CURL (recommended).

function get_content($URL){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = curl_exec($ch);
return $data;

echo get_content(‘’);

If you dont have curl installed on your server, here is some tips for CentOS:

yum install curl
yum install php-curl
yum install rh-php70-php-curl

The install of PHP depends on the version that you are using.