PHP 生成UUID的方法
1 public function guid(){
2 //检测是否存在函数
3 if (function_exists('com_create_guid')){
4 //创建全局唯一UUID标识.
5 return com_create_guid();
6 } else {
7 //随机数生成器. php4.2.0以上版本支持.
8 mt_srand((double)microtime() * 10000);
9 //基于以微秒计的当前时间,生成一个唯一的 ID
$unid = uniqid(rand(), true);
//将字符串转换为大写.
$charid = strtoupper(md5( $unid ));
// 从指定的 ASCII 值返回字符 "-"
$hyphen = chr(45);
// 从指定的 ASCII 值返回字符 "{"
$uuid = chr(123).substr($charid, 0, 8)
.$hyphen.substr($charid, 8, 4)
.$hyphen.substr($charid,12, 4)
.$hyphen.substr($charid,16, 4)
.$hyphen.substr($charid,20,12)
.chr(125);// 从指定的 ASCII 值返回字符 "}"
return $uuid;
}
}
PHP 生成UUID的方法的更多相关文章
- Oracle中生成uuid的方法
Oracle中生成uuid的方法 下载LOFTER客户端 在Oracle SQL 提供了一个生成uuid的函数sys_guid: http://download.oracle.com/docs/cd/ ...
- JS生成UUID的方法实例
<!DOCTYPE html> <html> <head> <script src="http://libs.baidu.com/jquery/1. ...
- JS生成 UUID的方法
方法一. function uuid() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i & ...
- jquery生成UUID的方法
来源: http://www.broofa.com/2008/09/javascript-uuid-function/ 1.代码: http://www.broofa.com/Tools/Math ...
- oracle和mysql在sql中生成uuid的方法
1,oracle sys_guid() 2,mysql uuid()
- PHP 生成 UUID 函数
Generate name based md5 UUID (version 3) /** * Generate name based md5 UUID (version 3). * @example ...
- SQL语句中生成UUID方法
SQL语句中生成UUID方法为UUID() 生成带横线UUID: select UUID() 形如:abaffaca-fd55-11e5-b3d0-d2 ...
- python基础-生成随机字符串方法
python解释器示例 >>> import uuid >>> uuid.uuid1() UUID('ae6822e6-c976-11e6-82e0-0090f5f ...
- linux c 生成uuid
/********方法一**********/#include <stdio.h> #include <stdlib.h> #include <string.h> ...
随机推荐
- 微软GitHub组织
微软aspnet团队的GitHub 微软dotnet团队的GitHub 微软的GitHub 微软云团队的GitHub 微软在GitHub的开源底部有其它组织
- python2 和3的区别
__future__ 模块 Python 3.x引入一些Python2不兼容的关键字和函数,可以通过在 Python2 内置的模块 __future__ 导入.建议如果你想在代码中支持 Python3 ...
- 布局文件提示错误“No orientation specified, and the default is horizontal. This is a common so...”
完整的错误提示信息为:No orientation specified, and the default is horizontal. This is a common source of bugs ...
- 监控代码运行时长 -- StopWatch用法例程
在.net环境下,精确的测量出某段代码运行的时长,在网络通信.串口通信以及异步操作中很有意义.现在做了简单的总结.具体代码如下: (1).首先 using System.Diagnostics; (2 ...
- iframe 重新加载闪过白块问题
在使用iframe时,iframe背景为白块,刷新时也会闪过白块.如果刷新时间长,就会一直出现白块,让人很烦恼,通过网上搜资料,测试最终解决方法如下所示,注意主要针对IE浏览器测试. 一.iframe ...
- UIView的交换实现,子视图交替变换
其中加了一些动画 2016-01-13 其中主要的方法有:Demo下载地址,Demo中有介绍:https://github.com/lizhaojie001/UIview.git
- hdu2309ICPC Score Totalizer Software
Problem Description The International Clown and Pierrot Competition (ICPC), is one of the most disti ...
- (原+转)Eclipse中Android调用OpenCv
大部分都是参考下面的网址,如果感觉看起来不舒服,可以直接查看原网址.最后遇到了一点问题: Description Resource Path Location Type E:/~\cod ...
- IE10以下placeholder不兼容
做页面的时候在谷歌中是显示的,但是换了IE之后总是不显示,一个文本框还好,如果有多个的话,如图: 添加以下一段Jquery代码: <script> var JPlaceHolder = { ...
- word保存时标题变成黑框(mac版本)
参考:http://blog.sina.com.cn/s/blog_686020310101i2zu.html 参考文档中说的时windows版本的word,跟我mac处理方式有一些不同: word版 ...