/**
* @Purpose:
* 创建唯一的uid
* @Method Name: create_guid()
*
* @Param:
*
* @Author: NoelXue
* @DATE:2017-10-13 14:52
* @Return:
/
public function create_guid(){
m
i
c
r
o
T
i
m
e
=
m
i
c
r
o
t
i
m
e
(
)
;
l
i
s
t
(
microTime = microtime(); list(
microTime=microtime();list(a_dec, $a_sec) = explode(" ", $microTime);
d
e
c
h
e
x
=
d
e
c
h
e
x
(
dec_hex = dechex(
dechex=dechex(a_dec 1000000);
s
e
c
h
e
x
=
d
e
c
h
e
x
(
sec_hex = dechex(
sechex=dechex(a_sec);
t
h
i
s
−
>
e
n
s
u
r
e
l
e
n
g
t
h
(
this->ensure_length(
this−>ensurelength(dec_hex, 5);
t
h
i
s
−
>
e
n
s
u
r
e
l
e
n
g
t
h
(
this->ensure_length(
this−>ensurelength(sec_hex, 6);
$guid = “”;
$guid .= $dec_hex;
$guid .= $this->create_guid_section(3);
$guid .= $this->create_guid_section(4);
$guid .= $this->create_guid_section(4);
$guid .= $this->create_guid_section(4);
$guid .= $sec_hex;
$guid .= $this->create_guid_section(6);
return $guid;
}
dechex($one)十进制转为16进制,$res = str_pad($input, 10, "==")使用另一个字符串填充字符串为指定长度
最新推荐文章于 2023-02-25 14:00:42 发布