伙计,伙计,我无法弄清楚...请帮忙。这里缺少什么?
以下是错误:
Notice: Uninitialized string offset: 62 in /..../libraries/functions.php on line 316
Notice: Undefined variable: stilldo in /..../libraries/functions.php on line 322
这是代码:
function generate_password($length = 12, $letters = true, $mixed_case = true, $numbers = true, $punctuation = false){
## Generate the alfa
$alfa = '';
if($letters == true) $alfa .= 'abcdefghijklmnopqrstuvwxyz';
if($mixed_case == true) $alfa .= strtoupper('abcdefghijklmnopqrstuvwxyz');
if($numbers == true) $alfa .= '0123456789';
if($punctuation == true)$alfa .= '~!@#$%^&*(),.=+<>';
## Set Random Seed
if(!function_exists('_generate_password_seed')):
function _generate_password_seed(){
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
endif;
srand(_generate_password_seed());
## Generate the password
$token = "";
for($i = 0; $i < $length; $i ++) {
$token .= $alfa[@rand(0, @strlen($alfa))];
}
## Check the length
if(strlen($token) < $length){
// echo $stilldo = $length - strlen($token);
$token .= generate_password($stilldo);
}
## Return the password
return $token;
}
我运行此功能的 10 次中有 5 次出现此错误,但我似乎无法破解它。