码迷,mamicode.com
首页 > 数据库 > 详细

mysql中php生成唯一ID

时间:2015-04-17 18:04:01      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:


<?php

//uniqid官方手册
function create_guid($namespace = ‘‘) { static $guid = ‘‘; $uid = uniqid("", true); $data = $namespace; $data .= $_SERVER[‘REQUEST_TIME‘]; $data .= $_SERVER[‘HTTP_USER_AGENT‘]; $data .= $_SERVER[‘REMOTE_ADDR‘]; $data .= $_SERVER[‘REMOTE_PORT‘]; $hash = strtoupper(hash(‘ripemd128‘, $uid . $guid . md5($data))); $guid = ‘{‘ . substr($hash, 0, 8) . ‘-‘ . substr($hash, 8, 4) . ‘-‘ . substr($hash, 12, 4) . ‘-‘ . substr($hash, 16, 4) . ‘-‘ . substr($hash, 20, 12) . ‘}‘; return $guid; } ?>

 

mysql中php生成唯一ID

标签:

原文地址:http://www.cnblogs.com/hubing/p/4435209.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!