Let\'s say I\'ve got a PHP function foo:
function foo($firstName = \'john\', $lastName = \'doe\') {
echo $firstName . \" \" . $lastName;
}
// foo(); --&g
You could refactor your code slightly:
function foo($firstName = NULL, $lastName = NULL)
{
if (is_null($firstName))
{
$firstName = 'john';
}
if (is_null($lastName ))
{
$lastName = 'doe';
}
echo $firstName . " " . $lastName;
}
foo(); // john doe
foo('bill'); // bill doe
foo(NULL,'smith'); // john smith
foo('bill','smith'); // bill smith