PHP Parse Error in yii2

PHP Parse Error – yii\base\ErrorException

syntax error, unexpected ‘(’, expecting ‘&’ or variable (T_VARIABLE)

How to solve this?someone please help

You can not put empty array as argument in a method declaration. Name it somehow like $arg and then set the default value to be empty array if you must.


public function findOne($cond, $arg = array())

What editor or IDE do you use for your work?

It’s very important to use good tools.

For example, PHPStorm will tell you that you can not make static method BaseActiveRecord::findOne() non static, and $form_detail_obj in updateNowForm method is an undefined variable, … etc.

A good tool is really a time saver. Please consider using one.

i got answer for that, i have changed that line as

public static function findOneRow($cond,$params=array()){

return Formdetail::find($cond,$params)->one();

}

Thanks for ur reply

I am using Eclipse mars ide.

It’s just my opinion, but NetBeans is a bit better than Eclipse + PDT, and PHPStorm is far better than the both. It’s not a free software, but it’s worth the price. Try it.

Okay thanks for your opinion…