关于php:文件格式UTF8与BOM导致“标题已发送” – 错误

File format UTF8 with BOM caused “headers already sent”-error

本问题已经有最佳答案,请猛点这里访问。

我收到错误消息:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/---/dbconnect.php:1) in /Applications/MAMP/htdocs/---/functions.php on line 84

这是dbconnect.php:

1
2
3
4
5
6
<?php if(!defined("INC")){
  define("INC", 1);
}
error_reporting(E_ALL);
require_once("config.mysqli.php");
@$mysqli = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname) or die("No Db found");?>

也尝试过:

1
2
3
4
5
6
7
8
<?php ob_start(null);
if(!defined("INC")){
  define("INC", 1);
}
error_reporting(E_ALL);
require_once("config.mysqli.php");
@$mysqli = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname) or die("No Db found");
ob_end_clean();?>

如果你需要更多的防护措施,请告诉我。谢谢!


看起来您可能有物料清单错误。有关详细信息,请参阅本文:session_start()错误