Just a quick and no doubt easy question. I’m pretty new to PHP and am looking through some existing code. I have tried to find the answer to my question on google, but to no avail.
Can somebody please let me know what the ‘&’ sign before the parameter $var does??
function setdefault(&$var, $default='') { if (! isset($var)) { $var = $default; } }
Passes it by reference.
Huh? Passing by reference means that you pass the address of the variable instead of the value. Basically you’re making a pointer to the variable.
http://us.php.net/language.references.pass