Home > Backend Development > PHP Tutorial > PHP的is_callable跟method_exists方法比较

PHP的is_callable跟method_exists方法比较

WBOY
Release: 2016-06-13 10:54:02
Original
992 people have browsed it

PHP的is_callable和method_exists方法比较

之前发过一篇关于is_callable的文章,主要是PHP手册的翻译,现在把is_callable和mehod_exists做一下比较,加深理解:

?

?

?

比较内容

method_exists

is_callable

调用形式

bool method_exists ( mixed $object , string $method_name )

bool is_callable ( callback $name [, bool $syntax_only = false [, string &$callable_name ]] )

适用范围

仅适用于判断类方法

可以判断全局函数,也可以判断类方法

是否有上下文

是,会判断一个函数是否在当前环境中可调用(例如在子类中判断能否调用父类构造函数)

是否判断权限

是,在类外,判断privateprotected方法会返回false

是否调用__call方法

速度

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template