B-219 Sec-55 Noida, India
+918010221733

file_get_contents not working?

It is not safe to turn on  allow_url_fopen  in php.ini due to various security reasons . You should use curl instead of file_get_contents . So if allow_url_fopen is turned off on your server you can use the below method to acheive the same target

function file_get_contents_curl($url) { 
        curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }

Comment below if it helps 🙂

(Visited 150 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.