Re: variable in function parameter
| From: | Curt Zirzow | Date: | Mon, 28 Jul 2003 14:52:02 +0000 |
| Subject: | Re: variable in function parameter | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157186@lists.php.net to get a copy of this message | ||
* Thus wrote CPT John W. Holmes (holmes072000@charter.net):
> > * Thus wrote 386-DX (murat@robcol.k12.tr):
> > > Hello. Let's say I have something like this:
> > >
> > > function aa($test) {
> > > $a = 8;
> > > echo $test;
> > > }
> > >
> > > $a = 2;
> > > aa("a is ". ($a>5?"greater":"equal to or less").
> > > " than 5".);
> >
> > http://php.net/eval
>
> No... you need to make $a global within the function for that change to
> affect $a outside the function
>
> function (...)
> {
> global $a;
> $a = 8;
>
> (can maybe do that in one operation, try it and see)
A yes, I did forget to mention that but as per requested I was
assuming they wanted the string test to be evalulated.
<snip>
I want this to output "a is greater than 5".. how can i modify the
code so that the function parameter is evaluated inside the
function?
</snip>
Curt
--
"I used to think I was indecisive, but now I'm not so sure."