╰┈➤ When variables are passed by reference, use & (ampersand) symbol need to be added before variable argument
function print_string(&$string) {
    $string = "Function string \n";
    echo($string);
}
$string = "Global string \n";
print_string($string);
echo($string);
// outputs: Function string, Global string
► Scope of both global and function variable becomes global as both variables are defined by same reference. Therefore, whenever global variable is change, variable inside function also gets changed. ◄
If we delete & (ampersand) symbol before variable, it outputs: Function string, Global string
by Luka Khitaridze
2 years ago
PHP
Variable
0
Pro tip: use ```triple backticks around text``` to write in code fences