function makeRandString($length) { $chr = array('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'); $string = ""; for ($i=0 ; $i<$length ;$i++){ $randNum = rand(0, 25); $string .= $chr[$randNum]; } return $string; }
一段php生成简单的随机字符串的函数,仅起到启发性作用。如想实现更复杂的,可以自己再尝试写一写