function addTen(int $n): void {
$n += 10; // modifies the local copy only
}
function addTenRef(int &$n): void {
$n += 10; // modifies the original
}
$x = 5;
addTen($x); // $x = 5
addTenRef($x); // $x = 15
Objects in PHP are passed by handle (a pointer to the object), not by value or reference. Modifying an object's properties inside a function is visible outside. But $obj = new OtherClass() is not (it replaces the local handle only).
Rarely needed in modern code. Prefer returning a new value from the function rather than mutating an argument. Justified for sort()-style functions or large structures to avoid copying.