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

后端 未结 5 1712
长发绾君心
长发绾君心 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:58

    When used with a function (not a class method) there is no difference except that function_exists is slightly faster.

    But when used to check the existence of methods in a class you cannot use function_exists. You'll have to use is_callable or method_exists.

提交回复
热议问题