I have written it in layouts/main.php
but whenever I am trying to run the application following error has been occured
Undefined property: CWebApplication::$user in ........ main.php on line...
And how its work can anyone please explain.
public static function model($className=__CLASS__)
{
return parent::model($className);
}
答案 0 :(得分:0)
尝试使用::
代替:
Yii::app()->user->name;
答案 1 :(得分:0)
如果要访问类的静态方法,请使用
classname::methodname();
所以,要访问类Yii {}
的静态app()方法class YiiBase {
public static function app() {
return self::$_app;
}
}
class Yii extends YiiBase {
}
Yii::app(); //You, need to do this