3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = null; print $a ?? 'b'; print "\n"; print $a ?: 'b'; print "\n"; print $c ?? 'a'; print "\n"; print $c ?: 'a2'; print "\n"; $b = array('a' => null); print $b['a'] ?? 'd'; print "\n"; print $b['a'] ?: 'd'; print "\n"; print $b['c'] ?? 'e'; print "\n"; print $b['c'] ?: 'e7'; print "\n";
Output for hhvm-3.15.4 - 3.21.3, 7.0.0 - 7.2.9
b b a Notice: Undefined variable: c in /in/2ZvAS on line 14 a2 d d e Notice: Undefined index: c in /in/2ZvAS on line 28 e7
Output for hhvm-3.22.0
b b a Notice: Undefined variable: c in /in/2ZvAS on line -1 a2 d d e Notice: Undefined index: c in /in/2ZvAS on line -1 e7
Output for 5.6.30
Parse error: syntax error, unexpected '?' in /in/2ZvAS on line 5
Process exited with code 255.