When to use public function xxxx in a class
When to use public static function xxx
Usually when writing classes, it is basically public function xxxx,
Because I am not very familiar with public static function xxx I understand, so I have basically never used it.
Could you please explain it in detail?
static is a static method that can be called directly using Class::functionName() without instantiation. At the same time, static methods are stored in the cache and are very fast. Public non-static methods need to be instantiated with new before they can be called using $class->functionName().
If your class is only instantiated once and used again, there will be no difference in use.
If there is a static method, you can call this method directly without instantiating the class.