Function Overloading in PHP
April 19th, 2005
Update: I have written about a more Java-like, argument based overloading solution here.
I’ve been trying to get a set of good basic functions included within my PHP framework and ran across a nice little trick to allow function (without a class) overloading, the code should speak for itself.
This will be the default file.
if(!function_exists("overloadableFunc") ) {
function overloadableFunc() {
echo "foo";
}
}
and this will be in the overloading file (needs to be included before the default.
function overoadableFunc() {
echo "foobar";
}