php 生成卡密
<?php//mt_rand 獲取隨機數 mt_rand(min, max);
$str="abcdefghijkmnpqrstuvwxyz0123456789ABCDEFGHIGKLMNPQRSTUVWXYZ";//設置被隨機采集的字符串
$codeLen='5';//設置生成的隨機數個數function str_rand($str,$codeLen){$rand="";for($i=0; $i<$codeLen-1; $i++){$rand .= $str[mt_rand(0, strlen($str)-1)]; //如:隨機數為30 則:$str[30]}return $rand;
}
$code=str_rand($str,$codeLen);
echo $code;?>
總結
- 上一篇: 前端学习(2007)vue之电商管理系统
- 下一篇: 卡密激活php代码,全自动PHP授权检测