I am using Yii-user module for authentication and I am trying to filter some output with user id.
class WordsController extends Controller
{
...
private $userObject = Yii::app()->getModule('user')->user();
...
}
This code shows this error:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in ...
I don't have an idea what is wrong.
Here is the link of the module https://code.google.com/p/yii-user/wiki/API
Your declaration of the class property is invalid. This usage is not allowed by PHP.
private $userObject = Yii::app()->getModule('user')->user(); // Invalid usage
To get around this, use the following : class WordsController extends Controller
{
...
private $userObject = null;
public function init()
{
$this->userObject = Yii::app()->getModule('user')->user();
}
...
}
See the PHP manual for more details: http://www.php.net/manual/en/language.oop5.properties.php