<?php
/*
**
** 生成随机密码
**
*/

function createPassword($psdLegth=6){
    $password = "";
    for($i=1;$i<=$psdLegth;$i++){
        $password .= chr(mt_rand(33,126));
    }
    return $password;
}

echo createPassword();

function createPassword1( $length = 6 ) {
    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
    $password = '';
    for ( $i = 0; $i < $length; $i++ ){
    // $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
    $password .= $chars[ mt_rand(0, strlen($chars) - 1) ];
    }
    return $password;
}

 

相关文章:

  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
猜你喜欢
  • 2021-08-13
  • 2022-12-23
  • 2021-11-29
  • 2021-11-29
  • 2021-11-14
相关资源
相似解决方案