...

View Full Version : Non-static method X should not be called statically?!



kaisellgren
05-15-2008, 06:52 PM
Hello,

I am having this error suddenly out of the blue:


Non-static method SpawConfig::getStaticConfigItem() should not be called statically, assuming $this from incompatible context

I'm using www.spaweditor.com in my PHP 5.2 website. My error reporting is set so that it does not display E_STRICT errors:


if (substr(phpversion(),0,1) != '6')
error_reporting(E_ALL);
else
error_reporting(E_ALL & ~E_STRICT);

by _Aerospace_Eng_ from: http://codingforums.com/showthread.php?t=139835

derzok
05-15-2008, 08:21 PM
Something tells me that you should ask the people at spaweditor.com - they would know their code a lot better than we would.

On a high level: A static method is a method that works on the class as a whole, not an instance of the class. Like in Java how you can have a Math object so that you can call Math.pow(2,4) (calculates 2^4). It would be silly to have to instantiate the math object just to do powers - instead you can call it independently of the object. What that error implies is that you have a class that has a static method. The static method is calling a function that is associated with an instance of the class, not the class itself. That would be like if Math.pow required an instance of the Math class to be instantiated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum