What exactly is the difference between the is_callable and function_exists in PHP?

后端 未结 5 1710
长发绾君心
长发绾君心 2021-02-01 01:22

I am working on a project, in which I am using a deprecated function from the older version. But don\'t want my script to stop if used in the older version.

So I am check

5条回答
  •  太阳男子
    2021-02-01 01:56

    If a function Plop exists then function_exists("Plop") will return true.

    See function_exists

    If a variable is callable then is_callable($var) will return true.
    Now this could mean that $var is a function name.
    But i could also be an object and method name combo.

    See is_callable

提交回复
热议问题