3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo{ private $bar = 'baz'; public function setBar($bar) { $this->bar = $bar; } } $h = function ($obj) { get_object_vars($obj); } $foo = new Foo(); $hydrator = Closure::bind( $h, new Foo(), // required blueprint! 'Foo' // setting correct class scope (in case of inheritances) ); var_dump($hydrator($foo)); $foo2 = new Foo(); $foo2->setBar('TAB!'); var_dump($hydrator($foo2));
Output for 5.4.16
Parse error: syntax error, unexpected '$foo' (T_VARIABLE) in /in/u2Oso on line 14
Process exited with code 255.
Output for 5.4.0 - 5.4.15
Parse error: syntax error, unexpected '$foo' (T_VARIABLE) in lFKbZ on line 14
Process exited with code 255.
Output for 5.3.25 - 5.3.26
Parse error: syntax error, unexpected T_VARIABLE in /in/u2Oso on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.24
Parse error: syntax error, unexpected T_VARIABLE in lFKbZ on line 14
Process exited with code 255.