Sharing some useful tips, solutions and notes for Geeks.

Thursday, August 25, 2016

Deprecated functionality: Non-static method should not called statically error fix

Today i met with one issue. One of my site in which i am currently working got some error like this:

Deprecated functionality: Non-static method OurClassName::ourmethod() should not be called statically on line ***

The main difference between Static and Non-static methods is that Static methods need not be initialized. Those can be called like this: OurClassName::ourmethod()

But for non Static ones, we cant use this as it might result in errors.

So to fix this, first we need an object and then intialize those method.

For this, you can call like this:

$ourobj = new OurClassName();

The error will be gone. :)

No comments: