如何生成uuid?
ci中如何生成uuid? 字符串辅助函数 string_helper.php的 random_string('md5')方法的返回值可以用来当uuid吗? 用 PHP 的 uniqid() 函数就可以了。 function uid($suffx = '', $length = 10) {// return uniqid($suffx);
$characters = '0123456789';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters;
}
return $suffx . $randomString;
};
demo1: uid(time());
demo2: uid(data('Ymd'));
试一下 function uid($suffx = '', $length = 10) {
// return uniqid($suffx);
$characters = '0123456789';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters;
}
return $suffx . $randomString;
};
demo1: uid(time());
demo2: uid(data('Ymd'));
试一下
页:
[1]