I was developing a site using Laravel 4. I had this piece of code in one of my models:
class MyModel extends Eloquent {
protected $var = array(
"label" => Lang::get("messages.label"),
"code" => "myCode",
);
...
}
But I gave this syntax error on the line where I used Lang::get
:
syntax error, unexpected '(', expecting ')'
Then I changed my code into this:
class MyModel extends Eloquent {
protected $var;
public function __construct() {
$this->var = array(
"label" => Lang::get("messages.label"),
"code" => "myCode",
);
}
}
And the error went gone! I think the error is very confusing and unhelpful. Why does php show this error message?