php页面出错

时间:2012-05-23 09:49:33

标签: php apache session cookies

我收到以下错误:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 3
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 38
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 39
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 52
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 52
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 38
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 39
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 52
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 52
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 76
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 77
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 96
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 96
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 96
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache2.2\htdocs\monitor.php:2) in C:\Apache2.2\htdocs\monitor.php on line 96

只要在session_start()和刷新cookie时就会出现。


同一页面(和代码)正在另一台机器上运行。 唯一的区别是安装的Apache服务器(我的是2.2.21,另一个是2.2.17)。

php版本是5.2.17,php.ini文件是相同的。


我该如何解决这种情况?

3 个答案:

答案 0 :(得分:0)

大多数情况下,在调用session_start()之前从php脚本发送内容/输出时会发生此错误。

通常在<?php之前,你可能有空格或其他标志/字母。 在您的情况下,问题出在monitor.php第2行 - 您可能在调用session_start()

之前回调

答案 1 :(得分:0)

php.ini文件是否相同?对我来说,听起来其中一个可能有output_buffering = on而另一个(失败的那个)有output_buffering = off。

http://www.php.net/manual/en/outcontrol.configuration.php

显然,默认情况取决于PHP的安装类型。

答案 2 :(得分:0)

您应该检查文件monitor.php的第二行,因为此行似乎会向浏览器输出一些文字。

在输出文字后,您无法执行session_start()