可能重複:
PHP Fix Warning: Cannot modify header information - headers already sent
「Warning: Headers already sent」 in PHP如何解決'警告:無法修改標題信息'錯誤?
我有一個不錯的網站,非常完美。第一頁是header.php文件,第一行是:
<?xml version="1.0" encoding="utf-8"?>
有一天我開始說語法錯誤行1。所以我做了網絡上的一些研究,改變了第一行到這一點:
<?php echo '<?xml version="1.0" encoding="utf-8"?>' ?>
解析錯誤問題消失了。但隨後另一個問題出現了:
Warning: Cannot modify header information - headers already sent by (output started at /Volumes/raid/Web/Sites/*******.com/header.php:1)
所以我決定從代碼中刪除這個第一行(和說實話,我不知道什麼是它的目的)。然後,一個新的錯誤出現:
Warning: Cannot modify header information - headers already sent by (output started at /Volumes/raid/Web/Sites/*******.com/header.php:25)
這裏的地方我找不到任何錯誤代碼(在行尾沒有空格,肯定)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd">
<html lang="fr" dir="ltr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/css/bootstrap.css" rel="stylesheet">
<link href="/css/style.css" rel="stylesheet">
<link type="image/x-icon" href="./img/lions_icon" rel="icon">
<link type="image/x-icon" href="./img/lions_icon" rel="shortcut icon">
<link href="/css/jquery.ui.all.css" rel="stylesheet">
<title>Lions</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script src="/js/jquery.js"></script>
<script src="/js/jquery-1.8.2.js"></script>
<script src="/js/jquery.ui.core.js"></script>
<script src="/js/jquery.ui.widget.js"></script>
<script src="/js/jquery.ui.datepicker.js"></script>
<script src="/js/bootstrap.js"></script>
<script>
$(function() {
$("#date").datepicker();
$("#date").datepicker("option", "dateFormat", "yy-mm-dd");
});
</script>
</head>
<?php
// beggining of the php code,
....
?>
<body>
...
線25是一個地方PHP開始。
這件事是我不輸出任何東西之前的頭()和錯誤說輸出發生25行或1行,如果我保持我的第一行(你可以看到在線程中)。 –