note 11675 deleted from Variable variables by jeroen
| From: | jeroen@php.net | Date: | Thu, 24 May 2001 00:25:39 +0000 |
| Subject: | note 11675 deleted from Variable variables by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14239@lists.php.net to get a copy of this message | ||
here's some strange behavior... if you run:
$arrayvar = array();
$regvar = 'arrayvar["idx"]';
$$regvar = 'Hello!';
then
$regvar is 'arrayvar["idx"]',
$$regvar is 'Hello!',
and
${arrayvar["idx"]} is "Hello!",
but $arrayvar["idx"] is empty!
SO, what's actually happening is that PHP has assigned a variable called
'arrayvar["idx"]', but (because it was assigned in a variable variable)
hasn't parsed it for brackets in order to make it an array! And when you try to use the
variable directly, it DOES parse for the brackets, therefore making the variable you intended to set
different from the one you actually set.