错误500;Endofscriptoutputbeforeheaders:index.php
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了错误500;Endofscriptoutputbeforeheaders:index.php,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3765字,纯文字阅读大概需要6分钟。
内容图文
![错误500;Endofscriptoutputbeforeheaders:index.php](/upload/InfoBanner/zyjiaocheng/206/3934504f313a4f079b7c9dcfd5a5ca95.jpg)
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)); }
回复讨论(解决方案)
打开 php 的错误显示,500 多半是被错误信息憋死的
从代码上看,最大的可能是内存不足
你好,平常没有怎么去接触错误显示的设置。 照网上设置,重启apache后。再执行,还是那种错误。我附上apache的完整点的错误日志吧,不过自己看不明白。
[Thu May 05 17:08:52.673028 2016] [core:warn] [pid 20268:tid 320] AH00098: pid file D:/phpStudy/Apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?[Thu May 05 17:08:52.811036 2016] [mpm_winnt:notice] [pid 20268:tid 320] AH00455: Apache/2.4.10 (Win32) OpenSSL/1.0.1i mod_fcgid/2.3.9 configured -- resuming normal operations[Thu May 05 17:08:52.811036 2016] [mpm_winnt:notice] [pid 20268:tid 320] AH00456: Apache Lounge VC9 Server built: Jul 19 2014 13:20:51[Thu May 05 17:08:52.811036 2016] [core:notice] [pid 20268:tid 320] AH00094: Command line: 'D:\\phpStudy\\Apache\\bin\\httpd.exe -d D:/phpStudy/Apache'[Thu May 05 17:08:52.814036 2016] [mpm_winnt:notice] [pid 20268:tid 320] AH00418: Parent: Created child process 21132[Thu May 05 17:08:54.476131 2016] [mpm_winnt:notice] [pid 21132:tid 336] AH00354: Child: Starting 150 worker threads.[Thu May 05 17:15:20.696222 2016] [core:error] [pid 21132:tid 1724] [client 127.0.0.1:60080] End of script output before headers: index.php
从代码上看,最大的可能是内存不足
我也一直在看运行过程中的内存,一直没有超过百分之八十
从代码上看,最大的可能是内存不足
我也一直在看运行过程中的内存,一直没有超过百分之八十
我再改下代码吧
系统内存 和 php 可用内存 不是一个概念
你就是个 500,神仙也不知道是怎么回事
php.ini 中令display_errors=On 打开错误提示功能再说吧
开启错误提示
系统内存 和 php 可用内存 不是一个概念
你就是个 500,神仙也不知道是怎么回事
额,是curl_multi_select()函数的问题,删掉那部分就可以了,不过照着参考文档上写的,都有问题,这我就不明白了。内存的不足的问题是在后面出现了,也解决了。多谢额。结贴
内容总结
以上是互联网集市为您收集整理的错误500;Endofscriptoutputbeforeheaders:index.php全部内容,希望文章能够帮你解决错误500;Endofscriptoutputbeforeheaders:index.php所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。