Tuesday, 23 January 2018

Function overloading

Shows how to "overload" functions

function Test(){

    $NumberOfArguments = func_num_args();

    for ($x=0; $x < $NumberOfArguments; $x++){
        $Argument = func_get_arg($x);   
        print $Argument . "\n";
    }

    // Another way:

    print_r(func_get_args());

}

Test('hello','world','foobar');
/*
returns:
hello
world
foobar
*/

0 comments:

Post a Comment