I have a static method defined in a class as follows:
class SomeEpicClass {
public static function iDoCrazyThings($param)
{
//All The Matrix computations occurring here
}
}
Now, I have two options for calling this method:
CASE 1
$instance = new SomeEpicClass();
$results1 = $instance->iDoCrazyThings(3.14159265);
$results2 = $instance->iDoCrazyThings(9.8);
CASE 2
$results1 = SomeEpicClass::iDoCrazyThings(3.14159265);
$results2 = SomeEpicClass::iDoCrazyThings(9.8);
Which of these cases has a better performance and why, please?
Best way to know what is better is check this out.
First static methods are nothing more than namespaced global functions.
When you should use the static method?:
when method is free of side effects.
The main adventage are:
this method will work still in the same way
you can use it without create a object