很抱歉再次提出这个常见问题,但我找不到答案。
所以我在我的menu.php中得到了这个错误,即时消息包括在我的索引中:
"Cannot modify header information - headers already sent by (output started at /home/andxeavr/public_html/bulfit.com/benching/index.php:61) in /home/andxeavr/public_html/bulfit.com/benching/includes/menu.php on line 20"
这是我的索引行61:
include('includes/menu.php');
这是我的menu.php:
if (isset($_POST['search_sub'])) {
header("Location: sign_up.php");
}
所以我尝试使用ob_start()和其他喜欢的答案,但是没有用。
最佳答案
这个问题已经被回答了太多次了:
How to fix "Headers already sent" error in PHP
但仍然:您可以尝试通过在文件顶部使用来避免标题位置已发送错误:
ob_start();
但也请尝试查看您的代码,看看是否没有多余的空间,并且在从文件开始启动php的开始标记之前没有任何空间。 :
<?php
header("Location: /");
?>
还要查看menu.php文件内部,您之前没有任何空间
<?php
然后做
<?php
关于php - header 位置已发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30909112/