3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<? 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.4.0 - 7.1.0
$arr = array(); var_dump($arr['foo']); Notice: Undefined index: foo in /in/FZVE3 on line 8 NULL $arr = array(); $obj = new stdclass(); var_dump($arr[$obj]); Warning: Illegal offset type in /in/FZVE3 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 4.3.0 - 5.3.29
<? 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']++; ?>