While making the static class for database getting this error

后端 未结 4 2138
鱼传尺愫
鱼传尺愫 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:46

    Properties may not be preset with runtime information.

    Quoting PHP Manual:

    Class member variables are called "properties". You may also see them referred to using other terms such as "attributes" or "fields", but for the purposes of this reference we will use "properties". They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration. This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.

提交回复
热议问题