cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: retrieving complete response using curl_exec()

From: Michael <lists.curl-and-php_at_mas.ml1.net>
Date: Sat, 05 Feb 2005 23:33:32 -0500

On Sat, 5 Feb 2005 23:10:14 +0500, "Brian Wilkins" <brian_at_hcc.net> said:
>
> >
> > <snip example of using CURLOPT_WRITEFUNCTION>
> >
> > I like that, but I'm not sure what gets you over the
> > CURLOPT_RETURNTRANSFER method. What's your rationale for using this
> > method instead?
>
> CURLOPT_RETURNTRANSFER will not return the results of the cURL query
> except in the contents that are returned in the curl_exec() method. If
> you do not use CURLOPT_RETURNTRANSFER set to 1, you will have to use
> some sort of method, like I have shown, to get the cURL query and
> $string = curl_exec() will return true/false (I believe).

Yes, that's right.

> I have no need to use CURLOPT_RETURNTRANSFER since the aforementioned
> procedure works just fine for me and there is no perceived performance
> hit by using that method.
>
> As far as rationale, there really was none. Part of it is laziness, I
> was not aware of the CURLOPT_RETURNTRANSFER when I first wrote my
> program, but I recently stumbled upon it. It's too tedious to convert
> all my code and test it. Therefore, I heed the credo : "Don't fix it,
> unless it is broken" :)

Always a good motto in my book. :)

OK, that's kind of what I thought, i.e. they're both equally effective
ways of doing the same thing. The CURLOPT_WRITEFUNCTION method would
allow you to do other clever stuff automagically with the returned
value, which in some cases could be useful but in my case doesn't add
value.

Thanks for the explanation.

Michael
Received on 2005-02-06