随机生成字符串
[php] function random($length) { $hash = ‘’; $chars = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abcdefghijklmnopqrstuvwxyz’; $max = strlen($chars) - 1; mt_srand((double)microtime() * 1000000); $chr_len = rand(3,$length); for($i = 0; $i < $chr_len; $i++) { $hash .= $chars[mt_rand(0, $max)]; } return $hash; } [/php]