How to debug a get request in php using curl How to debug a get request in php using curl curl curl

How to debug a get request in php using curl


Add a few more option for troubleshooting purposes.

Check for an error response.

If no error, get the details:

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);curl_setopt($ch, CURLOPT_TIMEOUT,10);curl_setopt($ch, CURLOPT_FAILONERROR,true);curl_setopt($ch, CURLOPT_ENCODING,"");curl_setopt($ch, CURLOPT_VERBOSE, true);curl_setopt($ch, CURLINFO_HEADER_OUT, true);curl_setopt($ch, CURLOPT_HEADER, true);$data = curl_exec($ch);if (curl_errno($ch)){    $data .= 'Retreive Base Page Error: ' . curl_error($ch);}else {  $skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));   $head = substr($data,0,$skip);  $data = substr($data,$skip);  $info = curl_getinfo($ch);  $info = var_export($info,true);}echo $head;echo $info;