3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test { public $foo = 10; protected $bar = 12; private $meh = 14; /** * @param string $key * @return boolean */ public function offsetExists($key) { return isset($this->{$key}); } /** * @param string $key * @return boolean */ public function offsetGet($key) { return method_exists($this, 'get'. ucfirst($key)) ? $this->{'get'. ucfirst($key)} : $this->{$key}; } /** * @param string $key * @param mixed $value */ public function offsetSet($key, $value) { method_exists($this, 'set'. ucfirst($key)) ? $this->{'set'. ucfirst($key)}($value) : $this->{$key} = $value; } /** * @param string $key */ public function offsetUnset($key) { unset($this->{$key}); } } $test = new Test; test var_dump(get_object_vars($test)); foreach($test as $param) { echo $param; }
based on 6oTdH
Output for 5.4.0 - 5.4.34
Parse error: syntax error, unexpected 'var_dump' (T_STRING) in /in/rKjAm on line 47
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/rKjAm on line 47
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/rKjAm on line 47
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/rKjAm 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/rKjAm 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/rKjAm on line 5
Process exited with code 255.