php - Expression is not allowed as field default value -
i trying make $app
available whole class. first
"expression not allowed field default value"
second on line 5 get:
unidentified variable $app
how can achieve goal?
class usercontroller extends xcontroller { var $app = yii::app();; public function init() { $test = $app;
you can not call method set default value variable in php, if static method. change set in constructor:
use yii; class usercontroller extends xcontroller { var $app; function __construct() { $this->app = = yii::app(); } public function init() { $test = $this->app; } }
as sidenote, should not use var
keyword in php versions > 4, see this question explanation.
Comments
Post a Comment