phpparameters

What does the & sign before the parameter name of a function do?


What does the & sign before the parameter $var do?

function setdefault(&$var, $default="")
{
  if (! isset($var))
  {
    $var = $default;
  }
}

    

Solution

  • 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