How can pass-by-reference be used to retrieve values from a PHP function?

Pass-by-reference in PHP allows us to modify the original value of a variable passed into a function, instead of just working with a copy of the value. To retrieve values from a PHP function using pass-by-reference, we can declare the function parameter with an ampersand (&) before the variable name. This indicates that the function will directly modify the original variable passed in.

function getValue(&$input) {
    $input = "New Value";
}

$originalValue = "Original Value";
getValue($originalValue);
echo $originalValue; // Output: New Value