3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $an_array = array(); $reflection = new ReflectionClass($an_object); $properties = $reflection->getProperties(); foreach ($properties as $property) { $property->setAccessible(true); $an_array[$property->getName()] = $property->getValue($an_object); if (!$property->isPublic()) $property->setAccessible(false); } var_dump($an_array);

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Notice: Undefined variable: an_object in /in/8rSAI on line 4 Fatal error: Uncaught ReflectionException: Class does not exist in /in/8rSAI:4 Stack trace: #0 /in/8rSAI(4): ReflectionClass->__construct('') #1 {main} thrown in /in/8rSAI on line 4
Output for Array change keys
Notice: Undefined variable: an_object in /in/8rSAI on line 4 Fatal error: Uncaught ReflectionException: Class does not exist in /in/8rSAI:4 Stack trace: #0 /in/8rSAI(4): ReflectionClass->__construct('') #1 {main} thrown in /in/8rSAI on line 4
Output for Lexical anon
Notice: Undefined variable: an_object in /in/8rSAI on line 4 Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in /in/8rSAI:4 Stack trace: #0 /in/8rSAI(4): ReflectionClass->__construct('') #1 {main} thrown in /in/8rSAI on line 4

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page