我有一个关于用户详细信息的课程。我想从我的应用程序中调用例如 UserDetails::$email ,但它是空的,因为它不执行构造函数。我应该如何解决这个问题?
<?php
class UserDetails {
public static $email;
private $password;
public static $role;
public static $active;
public function __construct() {
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->email = $auth->getIdentity()->email;
$this->password = $auth->getIdentity()->password;
$this->role = $auth->getIdentity()->role;
$this->active = $auth->getIdentity()->active;
}
}
}