您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> PHP >> 错误500 ;End of script output before headers: indexphp

错误500 ;End of script output before headers: indexphp

来源:网络整理     时间:2016/5/16 12:40:49     关键词:

关于网友提出的“错误500 ;End of script output before headers: indexphp”问题疑问,本网通过在网上对“错误500 ;End of script output before headers: indexphp”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:错误500 ;End of script output before headers: indexphp
描述:

PHP ThinkPHP  curl错误500多线程

ThinkPHP框架,用curl爬取某网站用ajax生成的分页数据,脚本最大执行时间设置为0.运行脚本一段时间后浏览器显示错误500:错误500 ;End of script output before headers: indexphp,apache错误日志报错:End of script output before headers: index.php。 代码如下:

public function multi(){
$page = 128;//ajax的分页数
$max_size = 10;//并发数
//url数组
$url_arr = array();
//生成url数组
for($i = 1;$i <= $page; $i++){
$url = 'http://www.wdzj.com/front_select-plat?params=&sort=0&currPage=';
$url .= $i;
$url_arr[] = $url;
}
$mh = curl_multi_init();
//每次只放出$max_size大小的url用来初始化
$count = count($url_arr);
for($i=0;$i<$count;$i++){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_arr[$i]);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_multi_add_handle($mh, $ch);
$requestMap[] = $ch;
if(count($requestMap)<$max_size && ++$i != $count) continue;//保证数组中每次有$max_size个请求且请求的url还没有用完
$active = null;
//执行批处理句柄
do{
$mrc = curl_multi_exec($mh, $active);
}while($mrc == CURLM_CALL_MULTI_PERFORM);
while($active && $mrc == CURLM_OK){
if(curl_multi_select($mh) != -1){
do{
$mrc = curl_multi_exec($mh, $active);
}while($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
$json_arr = array();//存放ajax返回的接口数据
//获取资源并且关闭句柄
foreach($requestMap as $ch){
$json_arr[] = curl_multi_getcontent($ch);
//  file_put_contents($i.'.txt', $json);
$error = curl_error($ch);
if($error != '') exit('发生了错误:'.$error);
curl_multi_remove_handle($mh, $ch);
}
unset($requestMap);
}
curl_multi_close($mh);
file_put_contents('1.txt', json_encode($json_arr));
}

解决方案1:

开启错误提示


ini_set('display_errors','on');
error_reporting(E_ALL);
?>
解决方案2:

php.ini 中令display_errors=On 打开错误提示功能再说吧

解决方案3:

系统内存 和 php 可用内存 不是一个概念
你就是个 500,神仙也不知道是怎么回事


以上介绍了“错误500 ;End of script output before headers: indexphp”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1107423.html

相关图片

相关文章