如何在PHP中基于当前日期时间和用户名生成随机激活码。
返回值应该是这样的,即:
201605021955用户名
function getActivationCode($username){
$activationCode = "";
....
return activationCode;
}
function getActivationCode($username){
$activationCode =date('YmdHi').$username;
return activationCode;
}
你想要的不是随机的,而是:
$string = date('YmdHi') . $username;
还可以检查chr函数,从随机数中获取字符(可以从mt_rand中获取)。