|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 14 22:00:01 2025 UTC |
Description: ------------ If I first assigned value by value, the result is correct. But if I first assigned value by references, result is very strange. <?php $array2 = array('ooo'); $array2[] =& $array2; $array2[] = $array2; xdebug_debug_zval(array2); ?> Above script will get bellow output: array2: (refcount=3, is_ref=1)=array (0 => (refcount=2, is_ref=0)='ooo', 1 => (refcount=3, is_ref=1)=..., 2 => (refcount=2, is_ref=0)=array (0 => (refcount=2, is_ref=0)='ooo', 1 => (refcount=3, is_ref=1)=..., 2 => (refcount=2, is_ref=0)=...)) but when run at "$array2[] = $array2", $array2[2] now haven't any value, but after assigned, it have a circle reference to $array2[2]... I think this is a bug... If this is't a bug, could tell me why? Test script: --------------- <?php $array1 = array('ooo'); $array1[] = $array1; $array1[] =& $array1; $array2 = array('ooo'); $array2[] =& $array2; $array2[] = $array2; print "<h1>Initial datas</h1>"; print <<< 'nowdoc' $array1 = array('ooo');<br /> $array1[] = $array1;<br /> $array1[] =& $array1;<br /> $array2 = array('ooo');<br /> $array2[] =& $array2;<br /> $array2[] = $array2;<br /> nowdoc; print "<h1>xdebug_debug_zval result:</h1>"; xdebug_debug_zval("array1"); print "<br />"; xdebug_debug_zval("array2"); print "<br />"; ?>