This is not going to go down as you might expect it should (even if you play smart and require/include_once):
<?php
if(function_exists('my_function'))
{
throw new Exception("'my_function' is already defined!");
}
function my_function()
{
}
?>
This, however does work:
<?php
if( ! function_exists('my_function'))
{
function my_function()
{
}
}
else
{
throw new Exception("'my_function' is already defined!");
}
?>
Does it have anything to do with PHP parse/execute phases or global/local scope or those curly brackets or something else, I have no idea, but the latter ugly son works, while the former bombs out claiming that 'my_function' is already defined.
Thought this might save someone a few minutes of debugging time...