Re: Variable variable
| From: | Rasmus Lerdorf | Date: | Wed, 18 Apr 2001 13:52:27 +0000 |
| Subject: | Re: Variable variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49213@lists.php.net to get a copy of this message | ||
> 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";
You can verify that you do indeed have a variable named $1 in your global
symbol table by doing:
echo $GLOBALS[1];
-Rasmus