2012-05-30 90 views
-4

可能重复:
Headers already sent by PHP警告:当我使用标题('Location:index.php)在PHP中的消息?

当我使用头(“位置:的index.php)在PHP代码它显示该错误消息。

警告:无法修改头文件信息 - 在D:\ xampp \ htdocs \ OnlineCode中已经发送的头文件(输出在D:\ xampp \ htdocs \ OnlineCode \ online \ survey \ code \ index.php:55中发送) \ online \ survey \ code \ index.php on line 62

我该如何解决这个问题?

+0

你已经发送了一些输出,例如。一些空格,标题必须在ANY输出之前发送 – Alex

+2

迂腐笔记:根据HTTP规范,Location需要完整的URL,而不是相对路径。另外,你是否试图谷歌这个?每10分钟询问一次。 – Corbin

+0

肯定重复:http://stackoverflow.com/questions/1827314/cannot-modify-header-information-headers-already-sent-why-its-happening和http://stackoverflow.com/questions/8028957/headers-已发送逐PHP –

回答

4

确保在重定向标头之前没有回显或打印语句。在重定向标头之前使用echo或print时会导致此错误。

0

当输出已经开始时会发生这种情况。您必须在任何输出发生之前放置header()调用。即使PHP标签之外的空间也算作输出。将页面的代码发布到可以查看它的位置可能会有帮助。