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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -