3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = ['bar' => '42']; var_dump($a['foo'] ?? 42); var_dump($a['bar'] ?? 42); var_dump((int) $a['foo'] ?? 42); var_dump((int) $a['bar'] ?? 42); var_dump((int)($a['foo'] ?? 42)); var_dump((int)($a['bar'] ?? 42));
based on vSEYW
Output for 7.0.0 - 7.3.0alpha1
int(42) string(2) "42" Notice: Undefined index: foo in /in/orugt on line 5 int(0) int(42) int(42) int(42)
Output for 5.6.0 - 5.6.28
Parse error: syntax error, unexpected '?' in /in/orugt on line 3
Process exited with code 255.