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->$key = $value; } var_dump($reflection);
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught ReflectionException: Cannot set read-only property ReflectionClass::$name in /in/e4S1E:17 Stack trace: #0 {main} thrown in /in/e4S1E on line 17
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Uncaught exception 'ReflectionException' with message 'Cannot set read-only property ReflectionClass::$name' in /in/e4S1E:17 Stack trace: #0 /in/e4S1E(17): unknown() #1 {main} thrown in /in/e4S1E on line 17
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/e4S1E on line 7
Process exited with code 255.