Linux 拨号vps windows公众号手机端

PHP中function_exists与method_exists有什么区别

lewis 8年前 (2017-09-13) 阅读数 7 #程序编程
文章标签 PHP

function_exists用于判断某个函数是否存在,而method_exists用于判断某个类的方法是否存在。

具体区别如下:

  1. function_exists用于全局函数,而method_exists用于类的方法。
  2. function_exists需要传入函数名作为参数,而method_exists需要传入类名和方法名作为参数。
  3. function_exists返回布尔值,表示函数是否存在,而method_exists返回布尔值,表示方法是否存在。
  4. function_exists可以用于任何函数,而method_exists只能用于类的方法。

总之,function_exists和method_exists都是用于检测函数或方法是否存在的函数,但用于不同的场景。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门