页面我使用了curl为什么会出现错误,希望高手看下是什么地方错了。。谢谢 curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$content = curl_exec($ch);
curl_close($ch);
为什么页面会出现PHP has encountered a Stack overflow
手册上这么说的:
TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
建议你设置CURLOPT_MAXREDIRS后重新测试。
由于你并没有贴全代码,无法进行测试估计是对方做了防抓取处理
设置一下 CURLOPT_USERAGENT、CURLOPT_REFERER 看看CURLOPT_MAXREDIRS 是设置重定向的最大次数
虽然可以缓解矛盾,但不能解决根本问题