xxxxxxxxxx
Default arguments
The default arguments must be constant expressions. They cannot be variables or function calls.
PHP allows you to use a scalar value, an array, and null as the default arguments.
xxxxxxxxxx
function some_function($args): void {
$val1 = $args[0];
// Access as normal index array
}
It's a pass by reference. The variable inside the function "points" to the same data as the variable from the calling context.
xxxxxxxxxx
function foo(&$bar)
{
$bar = 1;
}
$x = 0;
foo($x);
echo $x; // 1