通过改变$strPol变量原始数据内容,可天生包含不通内容的数据;
代码:
<?php/ @name RandString @desc 随机字符串 @author /class RandString {public static function getRandString($length) {$str = null;$strPol = \"大众ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz\公众;$max = strlen($strPol) - 1;for ($i = 0; $i < $length; $i++) {$str .= $strPol[rand(0, $max)]; //rand($min,$max)天生介于min和max两个数之间的一个随机整数}return $str;}}
调用办法:
echo '天生长度5的字符串:'.RandString::getRandString(5);