PHP 4.0 Bug #9217 Updated: Variable Variables not "setting" as expected
| From: | rasmus@php.net | Date: | Sun, 11 Feb 2001 20:55:57 +0000 |
| Subject: | PHP 4.0 Bug #9217 Updated: Variable Variables not "setting" as expected | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46392@lists.php.net to get a copy of this message | ||
ID: 9217
Updated by: rasmus
Reported By: laura@freschinfo.com
Old-Status: Open
Status: Closed
Bug Type: Variables related
Assigned To:
Comments:
Looks like you are confused about how variable variables work.
$a = "hello";
$$a = "world";
At this point $hello would be set to "world"
In your example I don't see $countrycodefinal set to anything and thus $$countrycodefinal
doesn't make much sense.
Previous Comments:
---------------------------------------------------------------------------
[2001-02-11 15:52:28] laura@freschinfo.com
Defined two variable variables. Expected each to have a different value, both ended up with same
value.
$counter = 0;
$$countrycodefinal = "ctrycode" . $counter;
$$aproposfinal = "aproposCitizen" . $counter;
echo ${$countrycodefinal} . "<br>";
echo ${$aproposfinal} . "<p>";
I expected the value of $$countrycodefinal to be "ctrycode0" and the value of
$aaproposfinal to be "aproposCitizen0", instead BOTH ended up with the value of
"aproposCitizen0".
I've repeated this several times whenever I use more than one variable variable in the same
script.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9217&edit=2