生成随机数
程序员文章站
2022-05-10 19:00:02
...
php代码
<?php /** *生成随机数 *@param */ function randStr($m = 5) { $new_str = ''; $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwsyz0123456789'; for ($i = 1; $i <= $m; ++$i) { $new_str .=$str[mt_rand(0, 61)]; } return $new_str; } //测试 $str = randStr(6); echo $str;