php生成随机字符串 复制即可用 //生成4位字符串 public function suijima() { $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $suijima = ''; //显示的个数 for( $i = 0; $i < 4; $i++ ){ $suijima .= $chars[ mt_rand(0, strlen($chars) - 1) ]; } return $suijima; }