<?php declare(strict_types=1); // references let a function swap caller variables function swap(&$a, &$b): void { [$a, $b] = [$b, $a]; } $x = 1; $y = 2; swap($x, $y); echo "$x $y\n";
two &-params exchange values