Before comparing is_callable and method_exists methods in PHP, I published an article about is_callable, which is mainly the translation of the PHP Manual. now I will compare is_callable and mehod_exists to better understand them :??? Comparison of is_callable and method_exists methods of method_existsis_call PHP
I have previously published an article about is_callable, mainly for the translation of the PHP Manual. now I will compare is_callable and mehod_exists to better understand:
?
?
?
|
Comparison content |
Method_exists |
Is_callable |
|
Call form |
BoolMethod_exists(Mixed$ Object, String$ Method_name) |
BoolIs_callable(Callback$ Name[, Bool$ Syntax_only= False [, string& $ Callable_name]) |
|
Applicability |
Only applicable to judgment methods |
You can determine global functions or class methods. |
|
Context? |
No |
Yes, it will determine whether a function can be called in the current environment (for example, in the subclass to determine whether the parent class constructor can be called) |
|
Determine the permission |
No |
Yes. when the private and protected methods are determined outside the class, false is returned. |
|
Call or not_ CallMethod |
No |
Yes |
|
Speed |
Fast |
Slow |
?