You can do this in Python, but is it possible in PHP?
>>> def a(): print 1
...
>>> def a(): print 2
...
>>> a()
2
The accepted answer is excellent!!! I will just add,that you can put your codes in Namespace brackets and then the default GLOBAL-SPACE is resetted.
1) rename_function($old_name,$new_name)
2) override_function($old_name, $parameters, $new_func)
and rarely used:
3) runkit_function_rename(...)
4) runkit_function_redefine(...)