Below is a simple script to generate random string/password using PHP.
You can customize the same by adding special characters.
<?php function randomPassword() { $alphabet = "abcdefghijklmnopqrstuwxyz ABCDEFGHIJKLMNOPQRSTUWXYZ 0123456789"; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 0; $i < $len; $i++) { $n = rand(0, $alphaLength); $pass[] = strtoupper($alphabet[$n]); } return implode($pass); //turn the array into a string } echo randomPassword($len); //length of the string ?>
Hope this is helpful.