error :should not be called statically, assuming $this from incompatible context. only on my machine

会有一股神秘感。 提交于 2019-12-05 15:25:20
Kleskowy

You probably have PHP running with E_STRICT error reporting. Try turning it off and see if that fixed the problem - like turn of error reporting for E_STRICT errors. See this post on SO :

<?php
error_reporting(E_ALL ^ E_STRICT);

But I have to say, it's a bad idea to mix object-style and static-style calls. Function calls should explicitly show that a function is called in a static or object context, and act accordingly. Even if it's a little hard (how hard is making a grep on all the files and change wrong calls?), i'd recommend fixing your code first.

And also I recommend reading about static keyword in Object Oriented Programming - there's a reason to distinguish static and object method calls, and it's not a reason of "to make things easier", but more of a "to make things clearer", I'd say.

Gerardo

Sorry but I do not write English very well, but what I understand your question is that:

you need to put your static function:

static public function functionName () {

   $data = ModelName :: functionName ($ param);

}

That happens through the different versions of PHP that the servers handle. I hope that I have understood your question and translate it well, because a similar error appeared to me and I solved it that way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!