Page 1 of 1

Putting cURL results in a variable

Posted: Wed Aug 12, 2009 10:16 am
by GeXus
Anyone know how to do this without curl printing the results?

I'm doing this:

Code: Select all

 
$result = curl_exec($ch);
 
But this prints the results on the screen, without having to specifically print $result

Re: Putting cURL results in a variable

Posted: Wed Aug 12, 2009 10:30 am
by onion2k
I'm pretty sure it doesn't echo it. Are you sure you're not echoing $result somewhere later in the code? Stick "exit();" immediately after the call to curl_exec() ... if you get a bank page then it's not echoing.

Re: Putting cURL results in a variable

Posted: Wed Aug 12, 2009 11:24 am
by Weirdan

Code: Select all

 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
onion2k wrote: I'm pretty sure it doesn't echo it.
Unfortunately you're wrong. By default curl_exec dumps everything it receives into standard output stream (that's being the webpage when you're running as apache module). CURLOPT_RETURNTRANSFER=true option tells it to not do so.