3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php var_dump(empty('')); var_dump(empty(0)); var_dump(empty(false)); var_dump(empty(null)); $a = 0; var_dump($a ?: 'a'); // empty var_dump($a ?? 'a'); // isset $a = ''; var_dump($a ?: 'a'); // empty var_dump($a ?? 'a'); // isset $a = false; var_dump($a ?: 'a'); // empty var_dump($a ?? 'a'); // isset $a = null; var_dump($a ?: 'a'); // empty var_dump($a ?? 'a'); // isset
based on X7RGp
Output for 7.0.0 - 7.3.0beta1
bool(true) bool(true) bool(true) bool(true) string(1) "a" int(0) string(1) "a" string(0) "" string(1) "a" bool(false) string(1) "a" string(1) "a"
Output for 5.5.0 - 5.6.28
Parse error: syntax error, unexpected '?' in /in/b7f5P on line 11
Process exited with code 255.