版权声明:本文为博主原创,未经博主同意,不得转载! https://blog.csdn.net/qq_39188306/article/details/84873568
/** * 随机字符串 * @param $lenth * @return string */ public function randStr($lenth){ $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $password = ''; for ($i = 0; $i < $lenth; $i++) { $password .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $password; }
//调用
public function index(){
$str = $this->randStr(30);
dd($str);
}