Re: Re: Variables inside a function
| From: | Jason Davidson | Date: | Tue, 09 Mar 2004 00:10:43 +0000 |
| Subject: | Re: Re: Variables inside a function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179845@lists.php.net to get a copy of this message | ||
you can reference the vars as well, but i would guess with some logic
changes you could avoid the problem your having?
Referencing ..
$blah = '';
function add(&$blah, $something, $somethingElse) {
$something ++;
$somethingElse ++;
$blah = $something + $somethingElse
}
John Kaspar <ljbn@hotmail.com> wrote:
>
> use the global keyword...
> http://www.php.net/manual/en/language.variables.scope.php
>
>
> On 3/7/2004 6:17 PM, Nathan Croker wrote:
>
> > I am relatively new to PHP. But something I can't seem to make work is when
> > I call one of the functions I have made and a variable is set inside that
> > function....
> > eg. function blah ($bl,$ah) {
> > $bl++;
> > $ah++;
> > $blah=$bl+$ah;
> > }
> > I then echo $blah; somewhere else in the script but nothing is echo'd. How
> > do I make it so that I can use $blah anywhere in the script?
> >
> > Thank you in advance for any help.
> > ------------------------
> > Nathan Croker
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>