php $$
- Started
- Last post
- 9 Responses
- ldww
just trying to understand $$ in php. here is what i have, let me know if i am doing this right.
$Foo = 'Bar';
$$Foo = 1;this would return Boo = 1, right? basically i want to set a name for a variable, and then later on i ned to set a value for whatever i named the variable.
- tomkat0
$Bar = 1;
- ldww0
i can not do it that simple, its more complex then that.
as i said i have to set a name, then later on name a variable the name set originally, and then set a value for it.
- tomkat0
we mean the same thing.
- ********0
$Foo = 'Bar';
$newFoo = (isset($foo));
echo ('$newFoo')
..I think that returns 1 (or true) if Foo has a value....
- ldww0
thanks moth, let me tru that
- ********0
oh.. check the caps - that last one was wrong..;
$Foo = 'Bar';
$newFoo = (isset($Foo));
echo $newFoo;I'm new at this... that might not be what you want...
- ldww0
that does not work, it does not change the name of the variable.
have you ever used double variables before? i mean '$$'. i thought i did this before and never had a problem.
- ********0
ok i was pissing up the wrong tree.
You were right the first time;
$foo = 'bar';
$$foo = 5;
echo $bar;this is exactly the equivalent of;
$bar = 5;
- mirola0
not sure what it is you're doing but i think you may be better off using ascociative arrays.