2011-12-27 55 views
0

(位置URL)在Zend的我使用header('Location: '.$redirect);重定向,但它會導致以下錯誤:錯誤:Zend的

Cannot modify header information - headers already sent by (output started at /application/controllers/IndexController.php:160)

有什麼不對?

回答

0

在Zend中:

您應該使用重定向器這樣的:

$this->_redirect('module/controller/action'); 

不PHTML文件!


如果你只使用PHP + HTML:

修剪重定向之前,所有白色字符。

可能在標題位置之前有一些白色字符。

例如,如果你有HTML頁面

______ Start of page ____________ 

<?php header('Location: http://www.example.com/'); ?> 

_________ end of page ___________ 

之前 '頭(...)' 你有 '\ n \ r' 和目前已經自動設置標題。