ADSFASFDA

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<?php
header('Content-Type:text/html;charset=utf8');
$_start=current_time();

$array1=range(1000,2000);
$i=0;
while ($i<200000){
    ++$i;
    // isset($array1[$i]); 55ms
    array_key_exists($i,$array1);// 80-90ms
}
$_end=current_time();
function current_time(){
    list($usec,$sec)=explode(' ',microtime());
    return ((float)$usec+(float)$sec);
}
echo '执行时间'.number_format($_end-$_start,3);
View Code

 通过microtime()测试isset()和array_key_exists执行时间

posted on 2017-03-07 00:46  778323309  阅读(152)  评论(0编辑  收藏  举报