2012-02-16 44 views
1

這是我收到的錯誤消息。我建立我自己的主題和它拉在一堆文件與functions.php在wordpress中收到錯誤消息「headers already sent」

Warning: Cannot modify header information - headers already sent by (output started at /home3/keganqui/public_html/dev/wp-content/themes/optimus/functions.php:5) in /home3/keganqui/public_html/dev/wp-includes/pluggable.php on line 866

新的functions.php文件,但出現同樣的錯誤消息:

<?php require(TEMPLATEPATH . '/inc/misc.php'); ?> 
<?php require(TEMPLATEPATH . '/inc/widgets.php'); ?> 
<?php require(TEMPLATEPATH . '/inc/homepage.php'); ?> 
<?php 
/* Include back-end */ 
if(is_admin()){ include TEMPLATEPATH.'/panel/panel.php'; } 

/* Include front-end */ 
if(!is_admin()){ include TEMPLATEPATH.'/panel/panel-front.php'; } 
?> 
+0

添加functions.php的前5行。 – fuxia 2012-02-16 03:45:20

+1

我不確定php是否關心第1-3行關閉php'?>'標籤後面的'\ n'換行符。這可能只是我,但我會刪除那些關閉並打開''標籤,並且只使用一個開始'<?php'和一個結尾'?>'標記。 – jeremysawesome 2012-02-16 04:06:09

+0

我同意傑里米 - 你應該刪除所有這些不必要的打開和關閉php標記。我更新了我的答案,以顯示他在說什麼...... – 2012-02-16 04:08:36

回答

2

機會是你有空白在你的<?php標籤之前。但正如toscho說,請與functions.php文件的第一行更新您的問題

UPDATE

您的功能文件應該是這樣的:

<?php 
require(TEMPLATEPATH . '/inc/misc.php'); 
require(TEMPLATEPATH . '/inc/widgets.php'); 
require(TEMPLATEPATH . '/inc/homepage.php'); 

/* Include back-end */ 
if(is_admin()){ include TEMPLATEPATH.'/panel/panel.php'; } 

/* Include front-end */ 
if(!is_admin()){ include TEMPLATEPATH.'/panel/panel-front.php'; } 
?> 
+0

我認爲你是正確的基於在網頁上出現錯誤。 +1 – 2012-02-16 03:53:20

0

必須只有一次,你的session_start ()在你打開php標籤後。 如果你有一個主頁,幷包含在帶有函數e.t.c的文件中,請不要在這些文件中再次使用session_start()。只需在您的主php文件中有一個session_start

+0

其中是pluggable.php中的session_start()...? – 2012-02-16 04:02:06

+0

你應該搜索它,導致輸出錯誤可能會誤導一些時候。你也有這麼多的開啓和關閉php標籤沒有理由。唯一的地方session_start應該是在所有這些代碼在你的第一個開始標籤的開始'<?php session_start()',之後沒有其他地方.. – Alexander 2012-02-16 04:10:21