这个JS代码转成PHP该怎么写呀? 10
e.prototype.createUID=function(){for(vare="",a="0123456789abcdef",o=0;8>o;o++)e+=a.ch...
e.prototype.createUID=function(){for(var e="",a="0123456789abcdef",o=0;8>o;o++)e+=a.charAt(Math.round(15*Math.random()));for(var o=0;3>o;o++){e+="-";for(var r=0;4>r;r++)e+=a.charAt(Math.round(15*Math.random()))}e+="-";var s=(new Date).getTime();e+=("000000000"+s.toString(16)).substr(-8);for(var o=0;4>o;o++)e+=a.charAt(Math.round(15*Math.random()));return t.__fuid=e,e}
展开
2个回答
展开全部
是将这个函数在php实现吗?代码:
function createUID() {
$e = '';
$a = '0123456789abcdef';
for ($o = 0; $o < 8; $o++)
$e .= $a[mt_rand(0, 15)];
for ($o = 0; $o < 3; $o++) {
$e .= '-';
for ($r = 0; $r < 4; $r++)
$e .= $a[mt_rand(0, 15)];
}
$e .= '-';
list($usec, $sec) = explode(' ', microtime());
$msec = intval($sec) * 1000 + intval(round(floatval($usec) * 1000));
$e .= str_pad(dechex($msec), 8, 0, STR_PAD_LEFT);
for ($o = 0; $o < 4; $o++)
$e .= $a[mt_rand(0, 15)];
return $e;
}
输出aa10653d-c69b-4bbc-fc25-9570c3b0d012
望采纳
function createUID() {
$e = '';
$a = '0123456789abcdef';
for ($o = 0; $o < 8; $o++)
$e .= $a[mt_rand(0, 15)];
for ($o = 0; $o < 3; $o++) {
$e .= '-';
for ($r = 0; $r < 4; $r++)
$e .= $a[mt_rand(0, 15)];
}
$e .= '-';
list($usec, $sec) = explode(' ', microtime());
$msec = intval($sec) * 1000 + intval(round(floatval($usec) * 1000));
$e .= str_pad(dechex($msec), 8, 0, STR_PAD_LEFT);
for ($o = 0; $o < 4; $o++)
$e .= $a[mt_rand(0, 15)];
return $e;
}
输出aa10653d-c69b-4bbc-fc25-9570c3b0d012
望采纳
追答
function createUID() {
$e = '';
$a = '0123456789abcdef';
for ($o = 0; $o < 8; $o++)
$e .= $a[mt_rand(0, 15)];
for ($o = 0; $o < 3; $o++) {
$e .= '-';
for ($r = 0; $r < 4; $r++)
$e .= $a[mt_rand(0, 15)];
}
$e .= '-';
list($usec, $sec) = explode(' ', microtime());
$msec = intval($sec) * 1000 + intval(round(floatval($usec) * 1000));
$e .= str_pad(dechex($msec), 8, 0, STR_PAD_LEFT);
for ($o = 0; $o < 4; $o++)
$e .= $a[mt_rand(0, 15)];
return $e;
}
因为格式有点问题,所以再发一个给你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询