php 隨機(jī)生成10位字符代碼
更新時(shí)間:2009年03月26日 11:31:09 作者:
php 隨機(jī)生成10位字符,大家可以看下原理就可以實(shí)現(xiàn)自定義位數(shù)的隨機(jī)字符串了。
復(fù)制代碼 代碼如下:
function randStr($len)
{
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; // characters to build the password from
$string='';
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$string.=substr($chars,$position,1);
}
return $string;
}
echo randStr(10)."<br>";
相關(guān)文章
PHP 與 UTF-8 的最佳實(shí)踐詳細(xì)介紹
這篇文章主要介紹了PHP 與 UTF-8 的最佳實(shí)踐詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2017-01-01
php實(shí)現(xiàn)模擬post請求用法實(shí)例
這篇文章主要介紹了php實(shí)現(xiàn)模擬post請求用法,分析了php模擬post請求的三種常見用法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07

