Thursday, April 14, 2011

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?

From stackoverflow
  • 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.

0 comments:

Post a Comment