我不断收到这个错误在我的日志文件:
[15-Jan-2013 00:50:04] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/usr/public_html/display.php:1) in /home/usr/public_html/display.php on line 17
所以我来看看页面上的第一行和我没有看到任何可能会发送标题的地方。
Display.php的:
<?PHP
require './err/errhandler.php';
require './assets/display.php';
require './assets/excrate.php';
$mysql_host = "sqlhost";
$mysql_database = "db";
$mysql_user = "user";
$mysql_password = "password";
$name = $_REQUEST["q"];
$type = $_GET["s"];
$timeperiod = $_POST["tp"];
$currency = $_POST["c"];
if(isset($currency)){
setcookie("prefCur", $currency, time()+60*60*24*30*12, "/");
$_COOKIE["prefCur"] = $currency;
} else {
if(!isset($_COOKIE["prefCur"])){
setcookie("prefCur", "usd", time()+60*60*24*30*12, "/");
$_COOKIE["prefCur"] = "usd";
}
}
...
errhandler.php:
<?PHP
ini_set('display_errors', false);
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__) . '/_err.log');
ini_set('output_buffering', 'on');
Display.php的:
<?PHP
function strip_name($name)
{
return preg_replace('/\s\([a-zA-Z 0-9]*\)/', '', preg_replace('/[0-9%]+\s/', '', str_replace(":", "", str_replace("-H", "-h", $name))));
}
excrate.php:
<?PHP $eur = 0.747807; $gbp = 0.621828; $rub = 30.227148;
然后,我不知道是否是我的主人是追加一个PHP文件,从而改变我的htaccess到:
php_value auto_prepend_file none
php_value auto_append_file none
Options +FollowSymLinks
...
我仍然得到错误,声称标头已经发出。我现在很难过。第一行发送标题的位置在哪里?我甚至无法启用输出缓冲,因为它在第一行!
编辑:在<?PHP
之前绝对没有什么,即使有输出缓冲,它也不起作用。它只是从线17将下移到线18
你的其他文件的内容是什么? – Daedalus
'$ _COOKIE [“prefCur”] = $货币;'是那个有效的代码? – Class
甚至没有你的PHP之前的空白空间或新行?甚至纯html?特别在你的包含文件中? –