|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-29 09:42 UTC] 576932087 at qq dot com
-Status: Open
+Status: Closed
[2015-12-29 09:42 UTC] 576932087 at qq dot com
[2015-12-29 20:57 UTC] requinix@php.net
-Status: Closed
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 11:00:02 2026 UTC |
Description: ------------ $data = [1,2,3]; foreach ($data as &$value) { } foreach($data as $value) { } var_dump($data); 在第二次foreach之后,通过xdebug打印的data显示结果: data: (refcount=1, is_ref=0)=array (0 => (refcount=1, is_ref=0)=1, 1 => (refcount=1, is_ref=0)=2, 2 => (refcount=2, is_ref=1)=2) Test script: --------------- $data = [1,2,3]; foreach ($data as &$value) { } foreach($data as $value) { } var_dump($data); Expected result: ---------------- array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } Actual result: -------------- array(3) { [0]=> int(1) [1]=> int(2) [2]=> &int(2) }