user2029890
user2029890

Reputation: 2713

PHP - Display cURL Verbose info

I'm having some trouble with a particular cURL command and I'd like to see the headers and responses. In the command line I use -v and it displays everything, however...

In PHP I'm attempting to use:

curl_setopt($curl, CURLOPT_VERBOSE, 1);

However, nothing is being displayed.

I'm using PHP 5.3.24 on Windows Server 2008 on IIS.

Supposedly the info is sent into the stderr stream which I assume means the regular log used for PHP errors - however nothing is going there either. I'm getting no header results for cURL commands that I know are working and those that I know are not working.

Upvotes: 5

Views: 12310

Answers (1)

user984869
user984869

Reputation: 432

My guess is that you need to also return the buffer. This code works under Linux and might work for you under Win2008:

$browser = curl_init();
curl_setopt($browser, CURLOPT_URL, $url);
curl_setopt($browser, CURLOPT_RETURNTRANSFER, true);
curl_setopt($browser, CURLOPT_VERBOSE, true);
$data = curl_exec($browser);
echo $data;

Upvotes: 7

Related Questions