#35560 [Asn->Bgs]: Failure on list($a, $b) = $b
| From: | dmitry@php.net | Date: | Mon, 12 Dec 2005 07:38:21 +0000 |
| Subject: | #35560 [Asn->Bgs]: Failure on list($a, $b) = $b | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90265@lists.php.net to get a copy of this message | ||
ID: 35560
Updated by: dmitry@php.net
Reported By: ktk at bigfoot dot com
-Status: Assigned
+Status: Bogus
Bug Type: Arrays related
Operating System: GNU/Linux
PHP Version: 5.1.1
Assigned To: dmitry
New Comment:
Duplicated. See http://bugs.php.net/bug.php?id=35277&edit=1
Previous Comments:
------------------------------------------------------------------------
[2005-12-05 21:39:06] tony2001@php.net
Dmitry, is there something we can do about it?
It definitely looks wrong to me, but somehow it works in 5.0.
------------------------------------------------------------------------
[2005-12-05 21:27:21] ktk at bigfoot dot com
Description:
------------
In PHP 5.1 the list() operator fails to correctly assign values to
variables that appear left of the variable that is used as the source
array, if the source variable is itself listed as one of the variables
to be assigned.
list($a, $b) = $b; fails to properly assign $a.
PHP 5.0 and earlier have no problem with this syntax.
Reproduce code:
---------------
$c = array("Apple", "Banana", "Pear", "Grape",
"Orange");
list($a, $b, $c, $d, $e) = $c;
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
var_dump($e);
Expected result:
----------------
string(5) "Apple"
string(6) "Banana"
string(4) "Pear"
string(5) "Grape"
string(6) "Orange"
Actual result:
--------------
string(1) "P"
string(1) "e"
string(4) "Pear"
string(5) "Grape"
string(6) "Orange"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35560&edit=1