Values & References10 / 16
Up next

Pass a scalar by reference

<?php
declare(strict_types=1);
// &$n binds the parameter to the caller's variable
function bump(int &$n): void {
    $n++;
}
$count = 5;
bump($count);
echo $count, "\n";
What you're solving

&$n lets the callee change it