Call a function while setting class properties

后端 未结 2 1581
广开言路
广开言路 2021-01-20 09:44

Is accessing functions while setting class properties possible in PHP (5.2 or 5.3) ?

class DAOClass {

   var $someProperty = SomeObject::staticMethod(\'read         


        
2条回答
  •  不知归路
    2021-01-20 10:06

    No. In the class declaration you define properties. You do not assign them anything. Everything after the = must be a literal constant. Method/function calls are expressions and cannot be used there.

提交回复
热议问题