php - How to use public public methods and public static static public methods in a class?
天蓬老师
天蓬老师 2017-05-16 13:15:33
0
2
897

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?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!