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

后端 未结 4 764
攒了一身酷
攒了一身酷 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:26

    I don't suggest you just hidding the stricts errors on your project. Intead, you should turn your method to static or try to creat a new instance of the object:

    $var = new YourClass();
    $var->method();
    

    You can also use the new way to do the same since PHP 5.4:

    (new YourClass)->method();
    

    I hope it helps you!

提交回复
热议问题