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> ...
随机推荐
- TI芯片android环境搭建和编译
1>. Reading package lists... Done Building dependency tree Reading state information... Do ...
- Python常用模块 (2) (loging、configparser、json、pickle、subprocess)
logging 简单应用 将日志打印到屏幕 import logging logging.debug('debug message') logging.info('info message') log ...
- [工作问题总结]MyEclipse 注册
------------------------------ASP.Net+Android+IO开发 .Net培训 期待与您交流!------------------------------ 1.本人 ...
- 数据库的优化tips
数据库 TIPS:: 1.用于记录或者是数据分析的表创建时::使用Id作为主键,1,2,3...表示消息条数.用户账号id用于做外键.一个用户相应唯一个accountId ...
- wso2esb源码编译总结
最近花了两周的空闲时间帮朋友把wso2esb的4.0.3.4.6.0.4.7.0三个版本从源码编译出来了.以下是大概的一些体会. wso2esb是基于carbon的.carbon是个基于eclipse ...
- 简单实现div+css页面自适应
Step1.在<head>添加如下代码<meta name="viewport" content="width=device-width, initia ...
- Node.js实践第一天
实践案例一 表单提交 demo.html <!doctype html> <html> <head> <title>表单提交</title> ...
- 清理SQL数据库日志
Use DBSelect NAME,size From sys.database_files ALTER DATABASE DB SET RECOVERY SIMPLE WITH NO_WAIT AL ...
- 搭建discuz论坛(2)
修改host文件: 使用ab做性能测试: E:\Apache2.2\bin>ab -n1000 -c100 http://bbs.ct.gd/
- USACO OPEN 12 BOOKSELF(转)
原文出处:http://txhwind.blog.163.com/blog/static/2035241792012112285146817/(版权为原作者所有,本博文无营利目的,不构成侵权) 题目大 ...