static function xautoload_Util::randomString in X Autoload 7.3
Generate a random string made of uppercase and lowercase characters and numbers.
Parameters
int $length: Length of the random string to generate
Return value
string Random string of the specified length
1 call to xautoload_Util::randomString()
- xautoload_ApcKeyManager_Enabled::renewApcPrefix in lib/
ApcKeyManager/ Enabled.php - Get a fresh APC prefix.
File
- lib/
Util.php, line 17
Class
- xautoload_Util
- A number of static methods that don't interact with any global state.
Code
static function randomString($length = 30) {
// $chars - allowed characters
$chars = 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . '1234567890';
srand((double) microtime() * 1000000);
$pass = '';
for ($i = 0; $i < $length; ++$i) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass .= $tmp;
}
return $pass;
}