I read somewhere that when you define a function you can define a default value for a variable that you might use or not use, like so:
function test( $a, $b, $c=0 ) {
if ( $c != 0 )
echo 'a + b + c = '.( $a + $b + $c);
else
echo 'a + b = '.( $a + $b );
}
I was wondering how many such variables with default values I can add when I define a function. Is it only one? or can I define multiple ones without getting a "function expects X variables to be passed" type of error? In other words can I do this?
function test( $a, $b, $c=0, $d=1, $e=2 ) {
if ( $c != 0 )
echo 'a + b + c = '.( $a + $b + $c);
else
echo 'a + b = '.( $a + $b );
}
and only call the function with test(4,9); ?