Alternative to Function Overloading in PHP 5
Posted: Mon Sep 08, 2008 10:37 am
Since I don't believe function overloading is availabe in PHP 5, is there a good alternate approach for having one function name capable of accepting different types/counts of parameters? Is there something better than checking the variable type within the function?
Code: Select all
function A(array) { // do something w/ the array }
function A(string) { // do something w/ the string }
A(array()); // calls the array version
A("string"); // calls the string version