瀏覽代碼

随机数

linwu 9 月之前
父節點
當前提交
c87c1b7bc9
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      app/common.php

+ 1 - 1
app/common.php

@@ -18,7 +18,7 @@ function rand_str($len = 6)
     $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $res = '';
     for ($i = 0; $i < $len; $i++) {
-        $key = rand(0, strlen($str));
+        $key = rand(0, strlen($str) - 1);
         $res .= $str[$key];
     }
     return $res;