我正在尝试通过一个继承的 Yii 框架站点。以前很少有面向对象的知识。
我正在打印一些用户信息,看看有什么像这样的......
print_r(Yii::app()->user);
那就是打印出这个...
CWebUser Object (
[allowAutoLogin] => 1
[guestName] => Guest
[loginUrl] => Array
(
[0] => /site/login
)
[identityCookie] =>
[authTimeout] => 7200
[autoRenewCookie] =>
[autoUpdateFlash] => 1
[loginRequiredAjaxResponse] =>
[_keyPrefix:CWebUser:private] => 7c6285462394c9a141b5d66dce54e8f2
[_access:CWebUser:private] => Array
(
[Admin] =>
[Judge] =>
[Student] => 1
)
[behaviors] => Array
(
)
[_initialized:CApplicationComponent:private] => 1
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
我正在尝试获取该用户是学生的信息。我看到了!在那里!
[Student] => 1
但是我如何才能得到这些信息呢?
更新:
这是 CWebUser 的部分似乎与 _access 有关
private $_access=array();
public function checkAccess($operation,$params=array(),$allowCaching=true)
{
if($allowCaching && $params===array() && isset($this->_access[$operation]))
return $this->_access[$operation];
$access=Yii::app()->getAuthManager()->checkAccess($operation,$this->getId(),$params);
if($allowCaching && $params===array())
$this->_access[$operation]=$access;
return $access;
}