php用Curl的post方法只获取header头信息中的Location
$posturl="http://www.ie81.com/posturl"; $postdata="a=1&b=2"; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL,$posturl); curl_setopt($ch, CURLOPT_REFERER,"");//REFERER curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $content = curl_exec($ch); curl_close($ch); // 解析HTTP数据流 list($header, $body) = explode("\r\n\r\n", $content); preg_match("/Location:([^\r\n]*)/i", $header, $matches); $Location = $matches[1]; if($Location!=""){ echo $Location } else{ echo "未获取到";}