标签:art mat new pen contract 使用 images current span
<?php class Test{ private $var=‘123‘; public function __get($name) { return $this->var; } } function current_time(){ list($usec,$sec)= explode(‘ ‘,microtime()); return ((float)$usec+(float)$sec); } $_start=current_time(); $i=0; while ($i<20000){ $i++; $t=new Test(); $t->var; } $_end=current_time(); header(‘Content-Type:text/html;charset=utf‘); echo ‘执行时间‘.number_format($_end-$_start,3);
public直接获取执行时间为
<?php class Test{ // private $var=‘123‘; public $var=‘123‘; /* public function __get($name) { return $this->var; }*/ } function current_time(){ list($usec,$sec)= explode(‘ ‘,microtime()); return ((float)$usec+(float)$sec); } $_start=current_time(); $i=0; while ($i<20000){ $i++; $t=new Test(); $t->var; } $_end=current_time(); header(‘Content-Type:text/html;charset=utf‘); echo ‘执行时间‘.number_format($_end-$_start,3);
4-1 减少PHP魔法函数的使用 __get($name)返回私有变量 取执行时间
标签:art mat new pen contract 使用 images current span
原文地址:http://www.cnblogs.com/jiaochengli/p/6512786.html