Back to Router class

Method setVar

public void
setVar
(mixed $key, mixed $value, mixed $create = true)
Set a router variable, creating it if it doesn't exist
Parameters
  • string $key The name of the variable
  • mixed $value The value of the variable
  • bool $create If True, the variable will be created if it doesn't exist yet
Returns
  • void
Since
  • 1.5
Class: Router
Project: Joomla

Method setVar - Source code

/**
 * Set a router variable, creating it if it doesn't exist
 *
 * @param   string   $key     The name of the variable
 * @param   mixed    $value   The value of the variable
 * @param   boolean  $create  If True, the variable will be created if it doesn't exist yet
 *
 * @return  void
 *
 * @since   1.5
 */
public function setVar($key, $value, $create = true)
{
    if ($create || \array_key_exists($key, $this->vars)) {
        $this->vars[$key] = $value;
    }
}