2013-04-08 95 views
1

致命錯誤:無法訪問受保護的屬性JException :: $代碼/.../templates/abrax/error.php線14個

行14-17:

if (($this->error->code) == '404') { 
header('Location: http://www.example.com/404'); 
exit; 
} 

回答

2

使用干將,你不能直接訪問屬性,因爲它的知名度不public

if (($this->error->getCode()) == '404') { 
... 
+0

我面對這個同樣的問題,我改變了代碼,如你所說,但其他錯誤顯示對我說:'致命錯誤:在無法使用方法的返回值寫上下文' 這是什麼意思? – 2013-04-16 13:05:04

+0

@JackZhang你究竟寫了什麼,你能複製錯誤的行嗎?你把'='代替了== ==嗎? – 2013-04-16 13:35:08

+0

這解決了這個問題。 Joomla 3.3 – davimusprime 2014-05-29 20:34:58

0

試試這個

if ($this->_error->get('code') == '404') { 
 
header('Location: http://www.example.com/404'); 
 
exit; 
 
}

相關問題