How can I check if the function my_function already exists in PHP?
And if my_function is in namespace:
namespace MyProject;
function my_function() {
return 123;
}
You can check if it exists
function_exists( __NAMESPACE__ . '\my_function' );
in the same namespace or
function_exists( '\MyProject\my_function' );
outside of the namespace.
P.S. I know this is a very old question and PHP documentation improved a lot since then, but I believe people still taking a peek here, and this might be helpful.