Jelajahi Sumber

优化:get_guid_v4方法兼容性

萤火科技 5 tahun lalu
induk
melakukan
6f4845e9dd
1 mengubah file dengan 3 tambahan dan 4 penghapusan
  1. 3 4
      app/common.php

+ 3 - 4
app/common.php

@@ -308,19 +308,18 @@ function get_guid_v4($trim = true)
         return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
     }
     // Fallback (PHP 4.2+)
-    mt_srand((double)microtime() * 10000);
-    $charid = strtolower(md5(uniqid(rand(), true)));
+    mt_srand(intval((double)microtime() * 10000));
+    $charid = strtolower(md5(uniqid((string)rand(), true)));
     $hyphen = chr(45);                  // "-"
     $lbrace = $trim ? "" : chr(123);    // "{"
     $rbrace = $trim ? "" : chr(125);    // "}"
-    $guidv4 = $lbrace .
+    return $lbrace .
         substr($charid, 0, 8) . $hyphen .
         substr($charid, 8, 4) . $hyphen .
         substr($charid, 12, 4) . $hyphen .
         substr($charid, 16, 4) . $hyphen .
         substr($charid, 20, 12) .
         $rbrace;
-    return $guidv4;
 }
 
 /**