问答详情
源自:4-1 减少PHP魔法函数的使用

<?php
 header('Content-type: text/html; charset=utf8');
function current_time(){
    list( $usec ,$sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
class Test{
	public $var = "123";
	public function __get($varname){
		return $this->var;
	}
}
$start = current_time();
$i = 0;
while ($i<10000) {
	$i++;
	$test = new Test();
	$test->var;
}
$end = current_time();
echo "Lost Time: ". number_format($end - $start,3)*1000;
echo "\n";

?>


提问者:跌落尘层的王者 2014-10-19 14:18

个回答