我有一个php代码的网站,本地测试运行都正常,但上线后主页http://www.yucolorworld.com/提示错误:

Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/includes/lib_base.php:1) in /home1/yucolorw/public_html/includes/cls_session.php on line 229Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/includes/lib_base.php:1) in /home1/yucolorw/public_html/includes/init.php on line 323Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/includes/lib_base.php:1) in /home1/yucolorw/public_html/includes/init.php on line 325Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/includes/lib_base.php:1) in /home1/yucolorw/public_html/includes/cls_template.php on line 109
后台管理页:http://www.yucolorworld.com/admin/ 提示错误
Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/admin/index.php:1) in /home1/yucolorw/public_html/includes/cls_session.php on line 229Warning: Cannot modify header information - headers already sent by (output started at /home1/yucolorw/public_html/admin/index.php:1) in /home1/yucolorw/public_html/includes/cls_template.php on line 109找了很多天也找不到啥原因造成的,在本地运行正常。
经过查找,问题应该是出在这步:
 if (preg_match('/^\s*location:/is', $string))    {          @header($string . "\n", $replace);
        exit();    }跳转不过去。
上网查说是:检查有 后面没有空白行,特别是include或者require的文件。不少问题是这些空白行导致的。
清理了有关文件的头部和尾部的空白行,但仍是解决不了错误。
请问处理过类似问题的高手,指点迷津。
谢谢,谢谢,谢谢。

解决方案 »

  1.   

    Cannot modify header information - headers already sent
    无法修改头信息-头已发送
    在 header 前已经有输出了,这是不允许的!(output started at /home1/yucolorw/public_html/includes/lib_base.php:1) in /home1/yucolorw/public_html/includes/cls_session.php on line 229
    是说:在执行 cls_session.php 第 229 行处的 header 函数时,发现 lib_base.php 的第一行处有输出
    这多半是 BOM 头引起的(通常上传到服务器时需要修改一些配置属性)如果你得的 php 版本高于 5.4,一般就不会出现此类问题了
    如果不能升级 php,可在 错误信息指向的程序文件的程序开始处加上 ob_start.();
      

  2.   

    你的header输出之后有其他输出,所以有这个问题。
    1.可能是utf8 bom导致,解决方法把bom去掉
    2.可能有其他例如空格等输出,可在出问题的文件顶加上ob_clean();处理。