3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function addOrIncr(&$arr, $key, $value) { $arr[$key] = ($arr[$key] ?? 0) + $value; } $arr = ['foo' => 1]; $value = 10; $key = 'foo'; $arr[$key] = ($arr[$key] ?? 0) + $value; $key = 'bar'; $arr[$key] = ($arr[$key] ?? 0) + $value; var_dump($arr);
Output for 7.0.0 - 7.2.0
array(2) { ["foo"]=> int(11) ["bar"]=> int(10) }
Output for 5.3.18 - 5.6.28
Parse error: syntax error, unexpected '?' in /in/ke0po on line 4
Process exited with code 255.