- function random($length)
- {
- $hash = '';
- $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
- $max = strlen($chars) - 1;
- mt_srand((double)microtime() * 1000000);
- for($i = 0; $i < $length; $i++)
- {
- $hash .= $chars[mt_rand(0, $max)];
- }
- return $hash;
- }
- //该片段来自于http://www.codesnippet.cn/detail/080320132328.html
来源: http://www.codesnippet.cn/detail/080320132328.html