3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar = 'baz'; public function getBar() { return $this->bar; } } $foo = new Foo; $time = microtime(true); for ($i = 0; $i <= 10000; $i++) { $ref = new ReflectionClass($foo); $property = $ref->getProperty('bar'); $property->setAccessible(true); $property->getValue($foo); } echo "REFLECTION: ", microtime(true) - $time, PHP_EOL; $time = microtime(true); for ($i = 0; $i <= 10000; $i++) { $foo->getBar(); } echo "GETTER: ", microtime(true) - $time, PHP_EOL;

preferences:
32.72 ms | 402 KiB | 5 Q