3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { public $data = array('foo' => 'bar'); public function get($key) { return array_key_exists($key, $data) ? $data[$key] : NULL; } } $foo = new Foo(); $result = !empty($foo->get('foo')); var_export($result); $result = !empty($foo->get('bar')); var_export($result);
Output for 5.5.24 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: data in /in/c8ggq on line 8 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/c8ggq on line 8 false Notice: Undefined variable: data in /in/c8ggq on line 8 Warning: array_key_exists() expects parameter 2 to be array, null given in /in/c8ggq on line 8 false
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: data in /in/c8ggq on line 8 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/c8ggq on line 8 false Notice: Undefined variable: data in /in/c8ggq on line 8 Warning: Invalid operand type was used: array_key_exists expects an array or an object; false returned. in /in/c8ggq on line 8 false
Output for 5.0.0 - 5.4.45
Fatal error: Can't use method return value in write context in /in/c8ggq on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/c8ggq on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/c8ggq on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/c8ggq on line 5
Process exited with code 255.