3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ParentClass { private $property = 'parent private property'; } class C extends ParentClass { private $property = 'child private property'; } $object = new C(); // Using ReflectionProperty $refProperty = new ReflectionProperty(ParentClass::class, 'property'); $refProperty->setAccessible(true); $startReflection = microtime(true); $reflectionValue = $refProperty->getValue($object); $endReflection = microtime(true); // Using array casting $startArray = microtime(true); $arrayValue = (array)$object; $arrayValueDirect = $arrayValue["\0" . ParentClass::class . "\0" . 'property']; $endArray = microtime(true); echo "Reflection Value: $reflectionValue\n"; echo "Array Casting Value: $arrayValueDirect\n"; echo "Reflection Time: " . ($endReflection - $startReflection) . " seconds\n"; echo "Array Casting Time: " . ($endArray - $startArray) . " seconds\n"; // Using ReflectionProperty $refProperty = new ReflectionProperty(ParentClass::class, 'property'); $refProperty->setAccessible(true); $startReflection = microtime(true); $reflectionValue = $refProperty->getValue($object); $endReflection = microtime(true); // Using array casting $startArray = microtime(true); $arrayValue = (array)$object; $arrayValueDirect = $arrayValue["\0" . ParentClass::class . "\0" . 'property']; $endArray = microtime(true); echo "Reflection Value: $reflectionValue\n"; echo "Array Casting Value: $arrayValueDirect\n"; echo "Reflection Time: " . ($endReflection - $startReflection) . " seconds\n"; echo "Array Casting Time: " . ($endArray - $startArray) . " seconds\n";
Output for git.master_jit
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 1.0013580322266E-5 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for git.master
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 8.1062316894531E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 1.1920928955078E-6 seconds

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

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


preferences:
27.05 ms | 407 KiB | 5 Q