3

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?

2 Answers 2

19

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

Sign up to request clarification or add additional context in comments.

Comments

6

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.