URL file-access problems in PHP
For many hosting providers it’s standart to disable URL file access. So, if your PHP code has file_get_contents(), require(), require_once(), include() or include_once() commands with some URL as a parameter, you will receive an error message: ‘URL file-access is disabled in the server configuration’.
To avoid this error you can try to use CURL.
Instead of this command:
$content = file_get_contents('http://sample_url');
You should use:
$ch = curl_init(); $timeout = 3; curl_setopt ($ch, CURLOPT_URL, 'http://sample_url'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $content = curl_exec($ch); curl_close($ch);
Sunday, March 30th, 2008