网站出现以下问题:
主页必须在 require('includes/application_top.php')前面或者application_top.php涉及到的文件中加入echo语句,才可以显示内容。
如果去掉就出现<dfj(dfj代表乱码),其它空白。打开调拭程序后,只看到一些notice之类的提示。
加入echo语句后,主页可以显示,但进入产品购物车就出现
Warning: Cannot modify header information - headers already sent by ....
其它空白。
在网上找到以下处理方法:
If you got this message: "Warning: Cannot modify header information - headers already sent by ...."
如果在执行php程序时看到这条警告:"Warning: Cannot modify header information - headers already sent by ...."
Few notes based on the following user posts:
有以下几种解决方法:
1. Blank lines (空白行):
Make sure no blank line after <?php ... ?> of the calling php script.
检查有<?php ... ?> 后面没有空白行,特别是include或者require的文件。不少问题是这些空白行导致的。
2. Use exit statement (用exit来解决):
Use exit after header statement seems to help some people
在header后加上exit();
header ("Location: xxx");
exit();
3. PHP has this annoying problem, if your HTML goes before any PHP code or any header modification before redirecting to certain page, it'll said "Warning: Cannot modify header information - headers already sent by ...." Basically anytime you output to browser, the header is set and cannot be modified. So two ways to get around the problem:
3a. Use Javascript (用Javascript来解决):
<? echo "<script> self.location(\"file.php\");</script>"; ?>
Since it's a script, it won't modify the header until execution of Javascript.
可以用Javascript来代替header。但是上面的这段代码我没有执行成功... 另外需要注意,采用这种方法需要浏览器支持Javascript.
3b. Use output buffering (用输出缓存来解决):
<?php ob_start(); ?>
... HTML codes ...
<?php
... PHP codes ...
header ("Location: ....");
ob_end_flush();
?>
但我试过这些方法,检测过提示涉及到的文件,还是同样的问题。
请问各位高手,这种情况怎么解决呢?
另外,我用的是godaddy免费空间,这会不会是空间问题呢?因为我在本地测试的没有任何问题,传到空间就出问题了。
小弟先谢了!


News