For example this is my class:
<?php
Class Example
{
public function example_function()
{
echo "example code";
}
}
?>
Which one of the following will be best, performance-wise?
1)
Example::example_function();
2)
$example = new Example();
$example->example_function();
What is the difference between them?
It not a matter of performance. It really isn’t. The difference, if there is one, is so minuscule as to be hardly measurable.
If you need to design your class with static methods, use static methods.
If you need to instantiate your class, you have no choice but to use object methods.
It’s a class design decision that has nothing to do with performance.