- time: documentation ( source)
<?php
class A {
private $x = 1;
function getX() {
return $this->x;
}
function __get($name) {
return $this->$name;
}
}
$a = new A();
$t = time();
for ($n = 0; $n < 100000; $n++) {
$a->getX();
}
echo time - $t();
$t = time();
for ($n = 0; $n < 100000; $n++) {
$a->x;
}
echo time - $t();