Jho*_*rra 0 php zend-framework
这是一些代码,它是我的控制器的基类,初始化所有常见值.该文件位于我的模型文件夹中,如果这有所不同.奇怪的是它在我正在开发的MAMP本地工作,但不在服务器上.我在想它可能是一个配置问题?
<?php
Zend_Loader::loadClass('Zend_Controller_Action');
class BaseController extends Zend_Controller_Action
{
protected $auth;
protected $current_user;
protected $db;
protected function initialize_values()
{
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$this->$current_user = $auth->getIdentity();
$this->view->user = $this->$current_user;
}
$this->db = Zend_Registry::get('dbAdapter');
$this->view->controller_name = $this->_request->getControllerName();
$this->view->view_name = $this->_request->getActionName();
}
}
Run Code Online (Sandbox Code Playgroud)
我把它放在if语句中的第一行
$this->$current_user = $auth->getIdentity();
Run Code Online (Sandbox Code Playgroud)
我理解这个错误意味着它试图访问不存在的属性或方法.在这种情况下,我知道存在