可能重复:
Cannot modify header information - headers already sent, Why its happening
Headers already sent by PHP
我网站上的所有页面都出错。
Warning: Cannot modify header information - headers already sent by (output started at
/home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 75
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5228
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5228
Warning: Cannot modify header information - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5232
Warning: Cannot modify header information - headers already sent by (output started at /home/payaim/public_html/directyourmoney/common.htm:3) in /home/payaim/public_html/directyourmoney/common.htm on line 5272
警告上面是我网站上的所有页面。 我删除了反映标题标签的空格和回声,我也搜索过但没有运气。 请帮帮我。
答案 0 :(得分:0)
如果您需要更具体的帮助,请提供您的代码。
但是,这意味着您尝试修改标题(例如使用header
函数或setcookie
一个`之后您已经发送了一些html行。这不是允许的。
在您的情况下,您正在尝试启动新会话,此操作需要发送cookie。这就是为什么在documentation中明确说明如果您要开始新会话,则应在页面顶部添加session_start
。
如果要修改标题,则必须先打印标题。
答案 1 :(得分:0)
在任何html输出之后你不能使用session_start()
这将有效:
<?php
session_start();
$some_value = 'something';
?>
这将不工作:
<?php
$some_value = 'something';
echo $some_value;
session_start();
?>
答案 2 :(得分:0)
以下内容可能会导致您发布的问题......
<html>
<head>
<title>blah</title>
<body>
<?php
session_start();
header("Location: http://www.google.com");
exit();
?>
</body>
</html>
或作为Matei Mihai说的
<?php
$some_value = 'something';
echo $some_value;
session_start();
?>