【PHP问题】Warning: Cannot modify header infor

92次阅读

共计 1111 个字符,预计需要花费 3 分钟才能阅读完成。

打开页面报错——

  1. Warning: Cannot modify header information – headers already sent by (output started at /users/remy/www/application/header.php:1) in /users/remy/www/application/function.php on line 25

复制代码

第 25 行内容为

  1. header(‘Content-Type:text/html;charset=utf-8’);

复制代码

请问是那里有问题?

网友回复:

注册 不能在已经输出个别字符之后再 header,要 header 必须在所有字符都没输出之前,空格,换行之类的也不行!

NoctuG 放到第一行,就可以了。

逸笙 谢谢大佬

feixiang 纯 PHP 小白,谢谢大佬提醒

NoctuG 我也是小白,刚好遇到并处理过这个问题 …

NoctuG 新问题 Warning: Cannot modify header information – headers already sent by (output started at /users/remy/www/application/header.php:1) in /users/remy/www/admin/index.php on line 9 Warning: Cannot modify header information – headers already sent by (output started at /users/remy/www/application/header.php:1) in /users/remy/www/admin/index.php on line 75 Warning: Cannot modify header information – headers already sent by (output started at /users/remy/www/application/header.php:1) in /users/remy/www/admin/index.php on line 81 复制代码 9 行 header(“Content-Type: text/html;charset=utf-8”); 75 行             setcookie(‘auth’, $setCOK, time() + 3600 * 24 * 14, ‘/’); 81 行             header(“refresh:2;url=” . $config[‘domain’] . “”); 复制代码

feixiang 你不能手痛就把手移到脑袋上啊。你要解决的是“在 header() 之前你已经有输出字符”这件事。我说了,不能有可见字符,也不能有空格,连换行都不能有!

正文完
 0