Let\'s say I\'ve got a PHP function foo:
function foo($firstName = \'john\', $lastName = \'doe\') {
echo $firstName . \" \" . $lastName;
}
// foo(); --&g
A variation on the array technique that allows for easier setting of default values:
function foo($arguments) {
$defaults = array(
'firstName' => 'john',
'lastName' => 'doe',
);
$arguments = array_merge($defaults, $arguments);
echo $arguments['firstName'] . ' ' . $arguments['lastName'];
}
Usage:
foo(array('lastName' => 'smith')); // output: john smith