Re: Two little questions

From: Date: Sun, 14 Jan 2001 17:17:13 +0000
Subject: Re: Two little questions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-34480@lists.php.net to get a copy of this message
> Then you must 'get' the global variables (like $name): > > $name = "mOrP"; > > function print_name() > { > global $name; > echo $name; > } > > print_name(); > > > But it's better to work with the function arguments: > > $name = "mOrP" > > function print_name($name_arg) > { > echo $name_arg; > } > > print_name($name); Ah, I see, so would something like this work: $alias = "James"; $password = "MyPassword"; function check_alias_password($alias_arg, $password_arg) { if ((!$alias_arg) || (!$password_arg)) { header("Location: login.php"); exit; } } check_alias_password($alias, $password); or function check_alias_password() global $alias, $password; { if ((!$alias) || (!$password)) { header("Location: login.php"); exit; } } check_alias_password(); work? Or would the last example need to be globals (variables) instead of global? > Hope it helps, It does, and your help is greatly appreciated ;) James.

« previous php.general (#34480) next »