[nycphp-talk] ini_set and file_get_contents
Leam Hall
leam at reuel.net
Thu May 7 10:26:40 EDT 2009
Brent, you are a wonderful person! No matter what Hans, Mitch, David,
and maybe a few others say... :)
Wasn't able to change anything that would allow file_get_contents but
the curl code you provided works like a charm! This is a growth point
for me so it's nice to be successful for a change.
Thanks!
Leam
Brent Baisley wrote:
> You should file_get_contents to retrieve URLs, which is what you seem
> to be trying to do. It doesn't handle failures (i.e. timeout,
> redirects) very well at all. You should use curl if you need to
> retrieve a remote file.
> $url = 'http://yourfile.com';
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
> $result = curl_exec($ch);
> if ( $result===false ) {
> echo curl_errno($ch).' '.curl_error($ch);
> }
> curl_close($ch);
>
> Obviously you would want to do something different in the event there
> is an error. Hopefully curl is enabled on your hosting server.
>
> Brent Baisley
>
More information about the talk
mailing list