在PHP中生成随机激活码[关闭]

How to generate random activation code based on current datetime and username in PHP.

The return value should be like this, i.e:

201605021955Username

function getActivationCode($username){
$activationCode = "";        

 ....

return activationCode;
}

What you are asking for is not random, but:

$string = date('YmdHi') . $username;

Also check out chr function to get a character from a random number (which you can get from mt_rand).

function getActivationCode($username){
    $activationCode =date('YmdHi').$username;  
    return activationCode;
}