Pass argument by reference

pass argument by reference:

In PHP You Used To Be Able To Preface A Variable With The & Symbol To Tell The Parser To Pass A Reference To The Variable, Not The Variable’s Value. This Granted A Function Access To The Variable


For example:
echo $a1." ".$a2." ".$a3."<br>";
echo $a1." ".$a2." ".$a3;
function fix_names(&$n1,&$n2,&$n3)

WILLIAM henry gatES
William Henry Gates

Rather than passing strings directly to the function, you first assign them to variables and print them out to see their “before” values. Then you call the function as before but put a & symbol in front of each parameter, which tells PHP to pass the variables reference only.

Translate »