While making the static class for database getting this error

后端 未结 4 2133
鱼传尺愫
鱼传尺愫 2020-12-22 10:05

Here is my class

class Databases {
    public $liveresellerdb = new Database(\'1host1\',\'user\',\'pswd\',\'db\');
}

the error i am gettin

4条回答
  •  眼角桃花
    2020-12-22 10:43

    Because you forgot to write the static keyword to actually make the property static.

    In addition, you can't initialise static properties with expressions like this. Here's a workaround.

提交回复
热议问题