📅  最后修改于: 2022-03-11 14:54:34.785000             🧑  作者: Mango
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
// Echo the random string.
// Optionally, you can give it a desired string length.
echo generateRandomString();