首頁 > 後端開發 > php教程 > php生成随机六位数密码_PHP教程

php生成随机六位数密码_PHP教程

WBOY
發布: 2016-07-20 11:16:16
原創
1190 人瀏覽過

<?<span php
</span><span //</span><span 随机产生六位数密码Begin</span>
<span function</span> randStr(<span $len</span>=6,<span $format</span>='ALL'<span ) { 
 </span><span switch</span>(<span $format</span><span ) { 
 </span><span case</span> 'ALL':
 <span $chars</span>='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~'; <span break</span><span ;
 </span><span case</span> 'CHAR':
 <span $chars</span>='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~'; <span break</span><span ;
 </span><span case</span> 'NUMBER':
 <span $chars</span>='0123456789'; <span break</span><span ;
 </span><span default</span> :
 <span $chars</span>='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~'<span ; 
 </span><span break</span><span ;
 } www.jbxue.com
 </span><span mt_srand</span>((<span double</span>)<span microtime</span>()*1000000*<span getmypid</span><span ()); 
 </span><span $password</span>=""<span ;
 </span><span while</span>(<span strlen</span>(<span $password</span>)<<span $len</span><span )
    </span><span $password</span>.=<span substr</span>(<span $chars</span>,(<span mt_rand</span>()%<span strlen</span>(<span $chars</span>)),1<span );
 </span><span return</span> <span $password</span><span ;
 } 
 </span><span //</span><span 随机产生六位数密码End</span>
?>
登入後複製

 

有关php生成随机密码或随机数的文章,脚本学堂已为大家提供了不少,有兴趣的朋友,可以阅读如下的文章:










www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440109.htmlTechArticle? randStr( =6, ='ALL' ( 'ALL': ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~'; 'CHAR': ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~'; 'NUMBER':...
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板