3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Person { } $array = [ 'name' => 'John', 'username' => 'JohnDoe23', 'is_active' => true ]; $reflection = new ReflectionClass('Person'); foreach($array as $key => $value) { $reflection->getProperty($key)->setProperty($value); } var_dump($reflection);
based on e4S1E
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught ReflectionException: Property name does not exist in /in/ljip0:17 Stack trace: #0 /in/ljip0(17): ReflectionClass->getProperty('name') #1 {main} thrown in /in/ljip0 on line 17
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Uncaught exception 'ReflectionException' with message 'Property name does not exist' in /in/ljip0:17 Stack trace: #0 /in/ljip0(17): ReflectionClass->getProperty('name') #1 {main} thrown in /in/ljip0 on line 17
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/ljip0 on line 7
Process exited with code 255.