3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $foo; protected $bar; protected $baz; } $aHydrator = function(array $data) { $this->a = $data['a']; $this->b = $data['b']; $this->c = $data['c']; } $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); $hydrated = new Foo(); $data = array('a' => 1, 'b' => 2, 'c' => 3); $a = new A(); ($aHydrator->bindTo($a, $a))($data); var_dump($hydrated);
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17, 7.0.0 - 7.0.2
Parse error: syntax error, unexpected '$data' (T_VARIABLE) in /in/Tca93 on line 17
Process exited with code 255.

preferences:
179.45 ms | 1395 KiB | 28 Q