如何获取curl响应头

时间:2019-04-21 09:45:50

标签: php curl header response

我想使用curl和post方法,然后我想获取诸如set-cookie等的响应头(不是响应源)
我怎样才能做到这一点? 我创建了以下代码,但只显示了响应源:

$ch = curl_init();
curl_setopt($ch, 
CURLOPT_URL,"https://www.example.com");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, 1);
$server_output = curl_exec ($ch);
echo ($server_output);

我尝试了getinfo($ch);

0 个答案:

没有答案