Unlike PHP 4, PHP 5 allows default values to be specified for parameters even when they are declared as by-reference:
-
-
function command_exists($command, &$output = null) {
-
$output = ‘whereis $cmd‘;
-
return true;
-
} else {
-
return false;
-
}
-
}
-
In the example above, the $output parameter is completely optional—if a variable is not passed in, a new one will be created within the context of command_exists() and, of
course, destroyed when the function returns.