3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['i' => 0]; var_dump($a['i'] ?: 'empty'); var_dump($a['i'] ?? 'empty'); var_dump($a['j'] ?: 'empty'); var_dump($a['j'] ?? 'empty'); var_dump($a['j'] ?? $a['i'] ?: 'empty');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
string(5) "empty" int(0) Warning: Undefined array key "j" in /in/pcVT3 on line 7 string(5) "empty" string(5) "empty" string(5) "empty"
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
string(5) "empty" int(0) Notice: Undefined index: j in /in/pcVT3 on line 7 string(5) "empty" string(5) "empty" string(5) "empty"
Output for 7.3.32 - 7.3.33
string(5) "empty" int(0) string(5) "empty" string(5) "empty" string(5) "empty"
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected '?' in /in/pcVT3 on line 6
Process exited with code 255.

preferences:
266.22 ms | 402 KiB | 331 Q