3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a[0] = 1; echo '$a: '; debug_zval_dump($a); $b =& $a[0]; echo "=============\n"; echo '$a: '; debug_zval_dump($a); echo '$b: '; debug_zval_dump($b); $c = $a; echo "=============\n"; echo '$a: '; debug_zval_dump($a); echo '$c: '; debug_zval_dump($c); $c[0] = 2; echo "=============\n"; echo '$a: '; debug_zval_dump($a); echo '$c: '; debug_zval_dump($c);
Output for 7.0.0 - 7.1.0
$a: array(1) refcount(2){ [0]=> int(1) } ============= $a: array(1) refcount(2){ [0]=> &int(1) } $b: int(1) ============= $a: array(1) refcount(3){ [0]=> &int(1) } $c: array(1) refcount(3){ [0]=> &int(1) } ============= $a: array(1) refcount(2){ [0]=> &int(2) } $c: array(1) refcount(2){ [0]=> &int(2) }
Output for hhvm-3.12.0
$a: array(1) refcount(2){ [0]=> long(1) refcount(1) } ============= $a: array(1) refcount(2){ [0]=> long(1) refcount(2) } $b: long(1) refcount(1) ============= $a: array(1) refcount(3){ [0]=> long(1) refcount(2) } $c: array(1) refcount(3){ [0]=> long(1) refcount(2) } ============= $a: array(1) refcount(2){ [0]=> long(2) refcount(3) } $c: array(1) refcount(2){ [0]=> long(2) refcount(3) }
Output for hhvm-3.10.0
$a: array(1) refcount(2){ [0]=> long(1) refcount(1) } ============= $a: array(1) refcount(2){ [0]=> long(1) refcount(1) } $b: long(1) refcount(1) ============= $a: array(1) refcount(3){ [0]=> long(1) refcount(1) } $c: array(1) refcount(3){ [0]=> long(1) refcount(1) } ============= $a: array(1) refcount(2){ [0]=> long(2) refcount(1) } $c: array(1) refcount(2){ [0]=> long(2) refcount(1) }
Output for 4.3.0 - 5.6.28
$a: array(1) refcount(2){ [0]=> long(1) refcount(1) } ============= $a: array(1) refcount(2){ [0]=> &long(1) refcount(2) } $b: long(1) refcount(1) ============= $a: array(1) refcount(3){ [0]=> &long(1) refcount(2) } $c: array(1) refcount(3){ [0]=> &long(1) refcount(2) } ============= $a: array(1) refcount(2){ [0]=> &long(2) refcount(3) } $c: array(1) refcount(2){ [0]=> &long(2) refcount(3) }