网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > PHP
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 49.87.3.231
Old 2014-12-28, 06:50 PM
Pagedale Pagedale is offline
初级会员
 
Join Date: 2012-09-29
Posts: 1
Pagedale 现在声名狼藉
Default php生成随机密码自定义函数代码(简单快速)

创建大量用户时一个一个想密码是让人头疼的事,使用php随机生成一个安全可靠的密码,又方便又快捷,可以添加自己想的字符串,可以用在FTP密码、Mysql密码、网站后台密码等地方.
实现代码,复制即用:

Code:
<?php
header("Content-type:text/html;charset=utf-8");
function getRandPass($length = 6){
 $password = '';
 //将你想要的字符添加到下面字符串中,默认是数字0-9和26个英文字母
 $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
 $char_len = strlen($chars); 
 for($i=0;$i<$length;$i++){
  $loop = mt_rand(0, ($char_len-1));
  //将这个字符串当作一个数组,随机取出一个字符,并循环拼接成你需要的位数
  $password .= $chars[$loop];
 }
 return $password;
}
echo getRandPass(12); //随机生成一个12位数的密码

?>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:39 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.