Re: Variable variable
| From: | Steve Werby | Date: | Wed, 18 Apr 2001 14:35:59 +0000 |
| Subject: | Re: Variable variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49223@lists.php.net to get a copy of this message | ||
"Rasmus Lerdorf" <rasmus@php.net> wrote:
> > 1. If $id is a number I believe PHP will choke b/c I don't believe
numbers
> > can be used as variable names.
>
> Well, generally that is true. If you try to assign a value directly to a
> variable that is a number such as:
>
> $1 = "Hello World";
>
> Then it won't work. However, due to a somewhat quirky implementation you
> can get arund this by doing:
>
> $a=1;
> $$a = "Hello World";
Sure enough, it works. Rasmus, can we expect this behavior to exist in
future releases of PHP? I prefer to give variables a meaningful name, but
since I spend a fair amount of time working with other people's code and
clients who sometimes insist on things that aren't preferable, it would be
nice to know.
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/