文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>php 取得唯一id

php 取得唯一id

时间:2008-04-05  来源:lib


                ?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$n = 100000;
print '1. (microtime): ';
$start = microtime(true);
for ($i=0; $i$n; $i++) {   
    $test = microtime();
}
print (microtime(true) - $start) . "s used \n";
print $test ."\n";
print '2. (microtime): ';
$start = microtime(true);
for ($i=0; $i$n; $i++) {   
    $test = microtime(true);
}
print (microtime(true) - $start) . "s used \n";
print $test ."\n";
print '3. uniqid:  ';
$start = microtime(true);
for ($i=0; $i$n; $i++) {   
    $test =  uniqid('uid', false);
}
print (microtime(true) - $start) . "s used \n";
print $test . "\n\n\n";
速度最快的是第三种
microtime()在php5后才支持传参返回float值,在多核的情况下,第2种方法也许会有重复值 ;在多机器环境下,要给值加不同的前缀区分不同的机器.还是原生php用的好。
               
               

相关阅读 更多 +
排行榜 更多 +
无烦恼厨房游戏正版中文版下载

无烦恼厨房游戏正版中文版下载

模拟经营 下载
锻刀模拟器手机版下载安装

锻刀模拟器手机版下载安装

模拟经营 下载
猎鱼达人3D手游官方版下载

猎鱼达人3D手游官方版下载

角色扮演 下载