3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array('foo' => 'bar'); foreach (array('foo', 'baz') as $key) { $var1 = $arr[$key] || 'fooDefault'; $var2 = $arr[$key] && $arr[$key]; var_dump($var1); var_dump($var2); }
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(true) bool(true) Notice: Undefined index: baz in /in/QlK4c on line 5 Notice: Undefined index: baz in /in/QlK4c on line 6 bool(true) bool(false)
Output for 4.3.0 - 5.2.17
bool(true) bool(true) Notice: Undefined index: baz in /in/QlK4c on line 5 Notice: Undefined index: baz in /in/QlK4c on line 6 bool(true) bool(false)