• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

CodeIgniter警告:Cannot modify header information 请好手帮忙

php 搞代码 3年前 (2022-01-23) 18次浏览 已收录 0个评论

CodeIgniter警告:Cannot modify header information 请高手帮忙
在控制器里面输入了这段代码

class Myfile1 extends CI_Controller
{
function myfile1()
{
来4源gaodaimacom搞#代%码*网搞代gaodaima码 $str=file_get_contents(‘./aa.txt’);
$str=$str?$str:0;
$str++;
file_put_contents(‘./aa.txt’,$str);
$str=file_get_contents(‘./aa.txt’);
echo $str;

然后运行 结果能正确输出$str; 但输出$str后 接着显示

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information – headers already sent by (output started at E:\AppServ\www\ci\application\controllers\myfile1.php:12)

Filename: core/Common.php

Line Number: 442

404 Page Not Found

The page you requested was not found.

不知道什么原因 请高手指点!!!

——解决方案——————–
建议给php装个xdebug,可以输出一个错误的所有追踪信息,然后你就知道这个header输出是怎么被调用的了
——解决方案——————–
程序已经告诉你问题所在了
headers already sent by (output started at E:\AppServ\www\ci\application\controllers\myfile1.php:12)
意思是在E:\AppServ\www\ci\application\controllers\myfile1.php第12出了状况.在header之前有内容输出
因为header头之前是绝对不能有内容输出的,所以就出现了你目前的状况.看看自己的代码,在哪里有不该出现的echo;print之类的玩意输出了内容.


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CodeIgniter警告:Cannot modify header information 请好手帮忙

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址