3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); // show all possible errors $obj = new stdclass(); $arr = array(); echo '$arr = array(); var_dump($arr[\'foo\']);'; var_dump($arr['foo']); echo "\n"; echo '$arr = array(); $obj = new stdclass(); var_dump($arr[$obj]);'; var_dump($arr[$obj]); echo "\n"; $arr = null; echo '$arr = null; var_dump($arr[\'foo\']);'; var_dump($arr['foo']); echo "\n"; echo '$arr = null; $obj = new stdclass(); var_dump($arr[$obj]);'; var_dump($arr[$obj]); echo "\n"; echo '$arr = null; $arr[\'i\'] = $arr[\'i\'] + 1;'; $arr['i'] = $arr['i'] + 1; echo "\n"; echo '$arr = null; $arr[\'i\']++;'; $arr['i']++; ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
$arr = array(); var_dump($arr['foo']); Notice: Undefined index: foo in /in/vSkNo on line 8 NULL $arr = array(); $obj = new stdclass(); var_dump($arr[$obj]); Warning: Illegal offset type in /in/vSkNo on line 11 NULL $arr = null; var_dump($arr['foo']);NULL $arr = null; $obj = new stdclass(); var_dump($arr[$obj]);NULL $arr = null; $arr['i'] = $arr['i'] + 1; $arr = null; $arr['i']++;
Output for hhvm-3.12.0
$arr = array(); var_dump($arr['foo']); Notice: Undefined index: foo in /in/vSkNo on line 8 NULL $arr = array(); $obj = new stdclass(); var_dump($arr[$obj]); Warning: Invalid operand type was used: Invalid type used as key in /in/vSkNo on line 11 Catchable fatal error: Object of class stdClass could not be converted to string in /in/vSkNo on line 11
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 5.2.17
$arr = array(); var_dump($arr['foo']); Notice: Undefined index: foo in /in/vSkNo on line 8 NULL $arr = array(); $obj = new stdclass(); var_dump($arr[$obj]); Warning: Illegal offset type in /in/vSkNo on line 11 NULL $arr = null; var_dump($arr['foo']);NULL $arr = null; $obj = new stdclass(); var_dump($arr[$obj]);NULL $arr = null; $arr['i'] = $arr['i'] + 1; $arr = null; $arr['i']++;