php - Unexpected observation: var_dump() of an array is flagging referenced elements... since when? -


i've been running simple debug tests against arrays, , noticed when var_dump() of array, output flagging element in array referenced variable. simple experiment, ran following code:

$array = range(1,4);  var_dump($array); echo '<br />';  foreach($array &$value) { }  var_dump($array); echo '<br />';  $value2 = &$array[1];  var_dump($array); echo '<br />'; 

which gives following output:

array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) }  array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> ∫(4) }  array(4) { [0]=> int(1) [1]=> ∫(2) [2]=> int(3) [3]=> ∫(4) }  

note ∫ symbol alongside element 3 , subsequently element 1. note entries don't show entry's datatype.

following experimentation, don't see if var_dump scalar type, or objects or resources. if array contains string data, symbol & (and still show datatype), likewise float, boolean , object entries.

this running against php 5.2.8

first question: when did behaviour start, or haven't noticed before now?

second question: if referenced elements can flagged in way var_dump(), there function in core php allow me identify if array element referenced variable; or return refcount or ref flag _zval_struct?

not sure if answers question, can use

debug_zval_dump($array); 

to refcount:

array(4) refcount(2){      [0]=> long(1) refcount(1)      [1]=> &long(2) refcount(2)      [2]=> long(3) refcount(1)      [3]=> &long(4) refcount(2)  }  

also see article derick rethans (php core dev) refcounting.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -