mysql中php生成唯一ID

时间:2015-04-17 18:01:38   收藏:0   阅读:261

<?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; } ?>

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!