<分区>
你好,我想在 php 中生成像 Ag7hlA 这样重复的随机字符串。有没有办法做到这一点我正在尝试这个
<?php
function random_string($length)
{
$length = (int) $length;
if ($length < 1) return '';
$base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789";
$max = strlen($base) - 1;
$string = '';
while ($len--)
{
$string = $base[mt_rand(0, $max)];
}
return $string;
}
?>
但是没有生成随机字符串