+
95
-

回答

还有一种方式

<?php
$url = 'http://bfw.wiki';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true); //返回头信息
curl_setopt($ch, CURLOPT_NOBODY, false); //不返回内容
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回数据不直接输出
$content = curl_exec($ch); //执行并存储结果

$hSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$body = substr($content, $hSize);
$header = substr($content, 0, $hSize);

curl_close($ch);
echo $header;
echo $body;
?>


网友回复

我知道答案,我要回答