添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Detailed curl Debugging in PHP Using the Output Buffer

//start the output buffer
ob_start();
$out = fopen('php://output', 'w');
$ch = curl_init();
//setting the curl options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//increase verbosity of curl output
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//store output in the stream we've initalized
curl_setopt($ch, CURLOPT_STDERR, $out);
//CURLINFO_HEADER_OUT silently causes CURLOPT_VERBOSE to fail
//curl_setopt($ch, CURLINFO_HEADER_OUT, 1); // capture the header info
$output = [];
$output['result'] = curl_exec($ch);
$output['info'] = curl_getinfo($ch);