Expression is not allowed as field default value

You can not call a method to set a default value for a variable in PHP, not even if it is a static method. Change it to be set in the constructor:

use Yii;

class UserController extends XController    
{
    var $app;

    function __construct() {
        $this->app = Yii::app();
    }

    public function init()    
    {
        $test = $this->app;
    } 
}

As a side note, you should not use the var keyword in PHP versions > 4, see this question for an explanation.

Leave a Comment