简体   繁体   中英

How to tell if a function is defined in php

How do I determine if a function is defined in php? I'd like to do something like:

if(! function_defined(money_format)) // function not defined on windows
{
      function money_format($str) { ... }
}

Is this possible in php?

You can use the function_exists function to determine if a function has been defined.

It's worth mentioning that you need to use method_exists to see if an object has a particular method defined.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM