file_get_contents in php7

If file_get_contents($url) generates error “Warning: file_get_contents(…) failed to open stream: Invalid argument in”, use this curl function below.


function curl_get_file_contents($URL){
//code sample
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);

if ($contents) return $contents;
else return FALSE;
}