Comparison between is_callable and method_exists methods in PHP

Source: Internet
Author: User
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

?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.