[nycphp-talk] ini_set and file_get_contents
Petros Ziogas
petros.ziogas at gmail.com
Mon May 11 04:07:30 EDT 2009
I liked the warm thanks, made my morning.
curl is very powerfull and it is a tool to have in your arsenal. The problem
is that many hosts have it disabled.
Petros Ziogas
http://www.royalblue.gr
On Thu, May 7, 2009 at 5:26 PM, Leam Hall <leam at reuel.net> wrote:
> 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
>>
>> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090511/d704bc5d/attachment.html>
More information about the talk
mailing list