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


Re: debugging curl

From: V. Simsive <>
Date: Fri, 28 Mar 2008 23:38:54 +0400

Hello Michael,

> I've been trying to use the code here to get debugging information
> <?php $curl = curl_init();
> curl_setopt ($curl, CURLOPT_URL, "");
> curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($curl, CURLOPT_VERBOSE, 1);
> curl_exec ($curl);
> curl_close ($curl); ?>
> Yet it is providing a response as a blank screen.

If you will enable only CURLOPT_VERBOSE all data will be sent to STDERR
as it is written in docs. and not to the browser (except the case when
you are executing script from SSH command line, in that case you
will see all debug data in your SSH window). To log debug information
you have to first: enable CURLOPT_VERBOSE and second: specify

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);

where $fp is file handle to output errors (in out case debug information)
to. e.g.

$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');

That code works fine for me ;) Hope my post helps

Best regards,
p.s. I hope this message will be added as replay and not as a new port :)
Received on 2008-03-28