如何判断是否在php中定义了一个函数

Byr*_*ock 3 php

如何确定是否在php中定义了一个函数?我想做点什么:

if(! function_defined(money_format)) // function not defined on windows
{
      function money_format($str) { ... }
}
Run Code Online (Sandbox Code Playgroud)

这可能在PHP?

cla*_*awr 19

您可以使用该function_exists函数来确定是否已定义函数.


Mar*_*iek 6

值得一提的是,您需要使用method_exists来查看对象是否定义了特定方法.