function yam($length){
$a="1234567890";
$b="qwertyuiopasdfghjklzxcvbnm";
$c="QWERTYUIOPASDFGHJKLZXCVBNM";
$d=$a.$b.$c;
for ($e=0;$e<$length;$e++){
//echo $d{mt_rand(1, strlen($d)-1)};
$f{$e}=$d{mt_rand(1, strlen($d)-1)};
}
return $f;
}
//yam(4);
$g=yam(4);
foreach ($g as $key=>$x){
echo $x;
}
$a="1234567890";
$b="qwertyuiopasdfghjklzxcvbnm";
$c="QWERTYUIOPASDFGHJKLZXCVBNM";
$d=$a.$b.$c;
for ($e=0;$e<$length;$e++){
//echo $d{mt_rand(1, strlen($d)-1)};
$f{$e}=$d{mt_rand(1, strlen($d)-1)};
}
return $f;
}
//yam(4);
$g=yam(4);
foreach ($g as $key=>$x){
echo $x;
}
2017-07-28
function getCode($length = 4) {
$varcode = "0123456789qwertyuiopasdfgjklzxcbnmvQWERTYUIOPASDLKFJHGZBXNCMV";
$relult = "";
for ($i = 0; $i < $length; $i++) {
$relult{$i} = $varcode{mt_rand(0,strlen($varcode))};
}
return $relult;
}
echo getCode();
$varcode = "0123456789qwertyuiopasdfgjklzxcbnmvQWERTYUIOPASDLKFJHGZBXNCMV";
$relult = "";
for ($i = 0; $i < $length; $i++) {
$relult{$i} = $varcode{mt_rand(0,strlen($varcode))};
}
return $relult;
}
echo getCode();
2017-07-11
$str2{1} = '' 输出 报错 Warning: Cannot assign an empty string to a string offset in E:\www\myself\string\index2.php on line 35
2017-06-13