localhost geht hop-fly nicht
This commit is contained in:
26
php/php-dog/classes/ranStr.php
Normal file
26
php/php-dog/classes/ranStr.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function random_str(
|
||||
$length,
|
||||
$keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
)
|
||||
{
|
||||
$str = '';
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
if ($max < 1)
|
||||
{
|
||||
throw new Exception('$keyspace must be at least two characters long');
|
||||
}
|
||||
for ($i = 0; $i < $length; ++$i)
|
||||
{
|
||||
$str .= $keyspace[random_int(0, $max)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo random_str(20);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user