Cannot access protected property JException::$code

≡放荡痞女 提交于 2019-12-11 07:27:50

问题


Fatal error: Cannot access protected property JException::$code in /.../templates/abrax/error.php on line 14

Lines 14-17:

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

回答1:


Use getters, you can't access property directly because it's visibility is not public

Like

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



回答2:


try this

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


来源:https://stackoverflow.com/questions/15870170/cannot-access-protected-property-jexceptioncode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!