3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array('a' => 'aa'); $x = new ArrayObject; $x[null] = array(); $x[null]['bar'] = 'foo'; ### this causes it # ---------------------------------------- function f($k) { $f = array('f' => 'ff'); return $f[$k]; } echo "ArrayObject dump:\n"; var_dump($x); echo "Non-existing array elements (current scope, function scope)\n"; var_dump($a['b'], f('b')); echo "Define a new variable: \$s='hohohoooo'\n"; $s = 'hohohoooo'; var_dump($a['b'], f('b')); echo "Define a new variable: \$n=1\n"; $n = 1; var_dump($a['b'], f('b'));
Output for 5.3.18 - 5.3.29, 5.4.8 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
ArrayObject dump: object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { [0]=> array(0) { } [""]=> array(1) { ["bar"]=> string(3) "foo" } } } Non-existing array elements (current scope, function scope) Notice: Undefined index: b in /in/p0fnK on line 20 Notice: Undefined index: b in /in/p0fnK on line 13 NULL NULL Define a new variable: $s='hohohoooo' Notice: Undefined index: b in /in/p0fnK on line 24 Notice: Undefined index: b in /in/p0fnK on line 13 NULL NULL Define a new variable: $n=1 Notice: Undefined index: b in /in/p0fnK on line 28 Notice: Undefined index: b in /in/p0fnK on line 13 NULL NULL
Output for 5.3.0 - 5.3.17, 5.4.0 - 5.4.7
Warning: Illegal offset type in /in/p0fnK on line 7 ArrayObject dump: object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> array(0) { } } } Non-existing array elements (current scope, function scope) Notice: Undefined index: b in /in/p0fnK on line 20 Notice: Undefined index: b in /in/p0fnK on line 13 array(1) { ["bar"]=> string(3) "foo" } array(1) { ["bar"]=> string(3) "foo" } Define a new variable: $s='hohohoooo' Notice: Undefined index: b in /in/p0fnK on line 24 Notice: Undefined index: b in /in/p0fnK on line 13 string(9) "hohohoooo" string(9) "hohohoooo" Define a new variable: $n=1 Notice: Undefined index: b in /in/p0fnK on line 28 Notice: Undefined index: b in /in/p0fnK on line 13 int(1) int(1)
Output for 5.2.0 - 5.2.17
Warning: Illegal offset type in /in/p0fnK on line 7 ArrayObject dump: object(ArrayObject)#1 (1) { [0]=> array(0) { } } Non-existing array elements (current scope, function scope) Notice: Undefined index: b in /in/p0fnK on line 20 Notice: Undefined index: b in /in/p0fnK on line 13 array(1) { ["bar"]=> string(3) "foo" } array(1) { ["bar"]=> string(3) "foo" } Define a new variable: $s='hohohoooo' Notice: Undefined index: b in /in/p0fnK on line 24 Notice: Undefined index: b in /in/p0fnK on line 13 array(1) { ["bar"]=> string(3) "foo" } array(1) { ["bar"]=> string(3) "foo" } Define a new variable: $n=1 Notice: Undefined index: b in /in/p0fnK on line 28 Notice: Undefined index: b in /in/p0fnK on line 13 array(1) { ["bar"]=> string(3) "foo" } array(1) { ["bar"]=> string(3) "foo" }
Output for 5.1.0 - 5.1.6
Warning: Illegal offset type in /in/p0fnK on line 7 Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /in/p0fnK on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Illegal offset type in /in/p0fnK on line 6 Warning: Illegal offset type in /in/p0fnK on line 7 Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /in/p0fnK on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/p0fnK on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/p0fnK on line 5