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 8.3.10, 8.3.13
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 8.3.12
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 8.8214874267578E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.3.9, 8.3.11
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.0599060058594E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.3.8
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 8.8214874267578E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.3.7
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 9.0599060058594E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.3.6
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: 0 seconds
Output for 8.1.2, 8.3.5
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 7.1525573730469E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.3.4
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 1.0013580322266E-5 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.3.3
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 6.9141387939453E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.1920928955078E-6 seconds Array Casting Time: 0 seconds
Output for 8.2.13, 8.3.2
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.0599060058594E-6 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 8.3.1
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 4.0531158447266E-6 seconds Array Casting Time: 1.7166137695312E-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 8.3.0
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.814697265625E-6 seconds Array Casting Time: 8.1062316894531E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.2.25
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 4.0531158447266E-6 seconds Array Casting Time: 9.5367431640625E-7 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 8.2.24
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.2.23
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 1.1920928955078E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.2.22
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.2.21
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 9.5367431640625E-7 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
Output for 8.2.20
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.2.19
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 1.1920928955078E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.2.18
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 9.5367431640625E-7 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 8.2.17
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 9.0599060058594E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.2.16
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-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
Output for 8.2.15
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 7.8678131103516E-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
Output for 8.2.14
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 7.8678131103516E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 1.1920928955078E-6 seconds
Output for 8.2.12
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 9.0599060058594E-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
Output for 8.2.11
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 8.1062316894531E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.2.10
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 8.1062316894531E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.2.9
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 6.9141387939453E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.2.8
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 4.0531158447266E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.2.7
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 5.0067901611328E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.2.6
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 7.1525573730469E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.2.5
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 6.9141387939453E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.1920928955078E-6 seconds Array Casting Time: 0 seconds
Output for 8.2.4
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 8.8214874267578E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.2.3
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-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: 0 seconds
Output for 8.2.2
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 9.0599060058594E-6 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 8.2.1
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.0599060058594E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.1920928955078E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.2.0
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: 0 seconds Array Casting Time: 0 seconds
Output for 8.1.30
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 2.1457672119141E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.0, 8.1.29
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.28
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 1.9073486328125E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.27
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 4.0531158447266E-6 seconds Array Casting Time: 7.8678131103516E-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
Output for 8.1.26
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 7.8678131103516E-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
Output for 8.1.25
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 9.0599060058594E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.24
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 6.9141387939453E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 1.1920928955078E-6 seconds
Output for 8.1.23
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 8.8214874267578E-6 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 8.1.22
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 6.1988830566406E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.1.21
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 0.0025300979614258 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.1920928955078E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.20
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.19
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 9.5367431640625E-7 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 8.1.18
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 1.9073486328125E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.17
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 1.9073486328125E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 1.1920928955078E-6 seconds
Output for 8.1.16
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.1.15
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 2.1457672119141E-6 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 8.1.14
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 0 seconds
Output for 8.1.13
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 2.1457672119141E-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
Output for 8.1.12
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 1.9073486328125E-6 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 8.1.8, 8.1.11
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 9.5367431640625E-7 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 8.1.10
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 9.5367431640625E-7 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.9
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 1.9073486328125E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.7
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.1457672119141E-6 seconds Array Casting Time: 6.9141387939453E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.6
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 1.9073486328125E-6 seconds Array Casting Time: 4.0531158447266E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.5
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 2.8610229492188E-6 seconds Array Casting Time: 4.0531158447266E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.4
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 7.8678131103516E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 0 seconds Array Casting Time: 9.5367431640625E-7 seconds
Output for 8.1.3
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 3.0994415283203E-6 seconds Array Casting Time: 7.8678131103516E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds
Output for 8.1.1
Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 5.9604644775391E-6 seconds Array Casting Time: 3.0994415283203E-6 seconds Reflection Value: parent private property Array Casting Value: parent private property Reflection Time: 9.5367431640625E-7 seconds Array Casting Time: 0 seconds

preferences:
50.71 ms | 519 KiB | 5 Q