How can I solve "Non-static method xxx:xxx() should not be called statically in PHP 5.4?

后端 未结 4 766
攒了一身酷
攒了一身酷 2020-12-03 16:33

Currently using a large platform in PHP.

The server it\'s hosted on has recently been upgraded to PHP 5.4.

Since, I\'ve received many error messages like:

4条回答
  •  没有蜡笔的小新
    2020-12-03 17:19

    Disabling the alert message is not a way to solve the problem. Despite the PHP core is continue to work it makes a dangerous assumptions and actions.

    Never ignore the error where PHP should make an assumptions of something!!!!

    If the class organized as a singleton you can always use function getInstance() and then use getData()

    Likse:

    $classObj = MyClass::getInstance();
    $classObj->getData();
    

    If the class is not a singleton, use

     $classObj = new MyClass();
     $classObj->getData();
    

提交回复
热议问题