脚本宝典收集整理的这篇文章主要介绍了从php curl发送请求头文件信息,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
如果要获取标题,请将选项CURLOPT_HEADER设置为1,并从curl_exec()返回的HTTP响应将包含标题.你可以解析他们的位置.
$ch = curl_init($url); curl_setopt($ch,CURLOPT_HEADER,1); // return HTTP headers wITh response curl_setopt($ch,CURLOPT_RETURNtransfer,1); // return the response rather than output it $resp = curl_exec($ch); list($headers,$response) = explode("\r\n\r\n",$resp,2); // $headers Now has a string of the HTTP headers // $response is the body of the HTTP response $headers = explode("\n",$headers); foreach($headers as $header) { if (strIPOs($header,'Location:') !== false) { echo "The location header is: '$header'"; } }
查看curl_setopt()的所有选项.
以上是脚本宝典为你收集整理的从php curl发送请求头文件信息全部内容,希望文章能够帮你解决从php curl发送请求头文件信息所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。