If you are are trying to use file_get_contents()
function to fetch the contents of a URL and you receive Error something like
Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0
Then you have following solutions
- Enable the
allow_url_fopen
parameter in yourphp.ini
configuration. Although this is an easy approach this is not recommended because of the security holes it opens. - Second way is to replace your
file_get_contents
call in your code withCURL
. This is a simple CURL method that behaves exactly same as file_get_contents.
function curl_get_file_contents($URL)
{
$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;
}
This simple method returns the content of the URL which is passed in as the parameter and returns FALSE is there is no content available.
Host Laravel Application on DigitalOcean
Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.
Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.