3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test { protected $a; public function getA() { return $this->a; } public function setA($a) { $this->a = $a; } } $test = new Test; $test->setA("foo"); $start_time = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== ($foo = $test->getA())) { echo $foo; } } $stop_time = MICROTIME(TRUE); $time = $stop_time - $start_time; PRINT "Elapsed time was $time seconds."; $start_time2 = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== ($foo = $test->getA())) { echo $foo; } unset($foo); } $stop_time2 = MICROTIME(TRUE); $time2 = $stop_time2 - $start_time2; PRINT "Elapsed time was $time2 seconds."; $start_time3 = MICROTIME(TRUE); for ($i=1; $i<=10000; $i++) { if ('' !== $test->getA()) { echo $test->getA(); } } $stop_time3 = MICROTIME(TRUE); $time3 = $stop_time3 - $start_time3; PRINT "Elapsed time was $time3 seconds.";