5 ms·
I agree keyword arguments are a better solution (but probably harder to implement). Right now this is how I do this: function salute($user, array $options
by frosas 14y ago
I agree keyword arguments are a better solution (but probably harder to implement).
Right now this is how I do this:
function salute($user, array $options = null) {
$options = (array) $options + array('shout' => false);
$salutation = "Hi $user!";
if ($options['shout']) $salutation = strtoupper($salutation);
return $salutation;
}
- smsm42 14y agoIt is significantly harder to implement, especially if you think about what happens with existing functions, especially internal ones.