123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkPHP [ WE CAN DO IT JUST THINK ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 流年 <liu21st@gmail.com>
- // +----------------------------------------------------------------------
- // 应用公共文件
- if (!function_exists('getNewRand'))
- {
- /**
- * 获取字母数字随机数
- * @param int $len
- * @return string
- * @author matielong
- */
- function getNewRand($len = 4)
- {
- $chars_array = array(
- "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
- "S", "T", "U", "V", "W", "X", "Y", "Z",
- );
- $charsLen = count($chars_array) - 1;
- $outputstr = "";
- for ($i=0; $i<$len; $i++)
- {
- $outputstr .= $chars_array[mt_rand(0, $charsLen)];
- }
- return $outputstr;
- }
- }
|