且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php,curl,headers和content-type

更新时间:2022-03-11 07:44:32

之前插入curl_exec()

curl_setopt($ch,CURLOPT_HEADER,true);

而不只是 echo '结果,也将标题转发给客户端:

Instead of just echo'ing the result, forward the headers to the client as well:

list($headers,$content) = explode("\r\n\r\n",$result,2);
foreach (explode("\r\n",$headers) as $hdr)
    header($hdr);
echo $content;