Re: Passing vars between functions (with POSTs)
| From: | Miguel Ribeiro | Date: | Wed, 16 May 2001 19:20:54 +0000 |
| Subject: | Re: Passing vars between functions (with POSTs) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-53094@lists.php.net to get a copy of this message | ||
Thanks for your reply but for example, my problem is more like the following
php3:
<?
$login='';
Function login() {
global $login;
echo('<form enctype="multipart/form-data" method="post"
action="test.php3?s=1"');
echo(' <p>Login</p><input type="text" name=login
size="10">');
echo('<input type="submit" value="Submit"
name="B1">');
echo('</form>');
}
function vrf_passwd($f1) {
printf("Login=%s",$f1);
}
switch($s) {
case 1: vrf_passwd($login);
break;
default: login();
break;
}
?>
"Rasmus Lerdorf" <rasmus@php.net> wrote in message
news:Pine.LNX.4.33.0105161127220.990-100000@rasmus.php.net...
> > I've tried other ways but my problem still continues... I can not pass
> > $login var out of the function.
> >
> > I don't have this problem in the two previous functions because I pass
this
> > variable as function argument, but this last function that doesn't have
> > arguments I can't see the $login (even if is setup on the previous
function
> > as global). I don't know why I PHP doesn't allow to setup a $login as
global
> > to all functions (this will solve this problem).
>
> It does. You simply have to declare in the function you wish to access
> the global variable that you want the global variable by using the global
> keyword in that function.
>
> Please read the Variables Scope chapter in the manual:
>
> http://php.net/manual/en/language.variables.scope.php
>
> -Rasmus
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>