• BOOKMARK

  • ADD TO FAVORITES

  • REFERENCES


  • MARC

    Mailing list ARChives
    - Search by -
     Subjects
     Authors
     Bodies





    FOLDOC

    Computing Dictionary




  • Text Link Ads






Generate a Random Password with PHP

PHP Tutorials.

Generate a Random Password with PHP

New postby Cat on Sat Dec 28, 2013 1:54 pm

Notes:
1. You can add more charactors, numbers or lower case charactors to '$possible_charactors' is you wish.
2. You can change the string length, for example, echo 'Random_Password(16);' for 16 charactors.

Code: [Select all] [Expand/Collapse] [Download] (Untitled)
<?
function Random_Password($length) {
<? phpdoc("srand") ?>(<? phpdoc("date") ?>("s"));
$possible_charactors = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while(<? phpdoc("strlen") ?>($string)<$length) {
$string .= <? phpdoc("substr") ?>($possible_charactors,(<? phpdoc("rand") ?>()%(<? phpdoc("strlen") ?>($possible_charactors))),1);
}
return($string);
}
<? phpdoc("echo") ?> Random_Password(8);
?>



Anyone who wishes to make additions or changes to this tutorial email them to webmaster@linuxguruz.com
User avatar
Cat
 
Posts: 15
Joined: Thu Dec 26, 2013 7:21 pm

Return to PHP Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

  • MORE RESOURCE


  • Linux

    The Distributions





    Linux

    The Software





    Linux

    The News



  • MARKETING






  • Toll Free
cron