Defining a value in the parameter list makes that parameter optional. If it's not provided when the function is called, the it takes on the value assigned to it.
Your specific example doesn't really make use of the feature effectively. Take something like this for example though:
function findFiles($directory, $includeHidden = false){
$iter = new DirectoryIterator($directory);
$list = [];
foreach ($iter as $item){
if ($item->isFile()){
$isHidden = $item->getFilename()[0] === '.';
if ($includeHidden || !$isHidden){
$list[] = $item->getPathname();
}
}
}
return $list;
}
That function requires at least one parameter when it's called, the directory to search. So you end up with the following options for calling it
$files = findFiles('/home/kicken'); /* executes with $directory = '/home/kicken', $includeHidden = false */
$files = findFiles('/home/aoeex', true); /* executes with $directory = '/home/aoeex', $includeHidden = true */