In the code pasted bellow the function accepts 2 arguments
I know that the first argument - $dir
- is passed into the function when it is called and the data is accessed using the variable $dir
.
However the second argument confuses me.
I have never seen a argument written in this way before does it set the value of $ext
as ".php"
?
if yes why is this done in included in the arguments at all (it could be declared inside the function itself?
if no then what is it doing?
public static function register($dir, $ext = '.php')
{
$autoloader = new static($dir, $ext);
spl_autoload_register([$autoloader, 'load']);
return $autoloader;
}