From d9ddf987f43972feffd24df33859321ac51008ed Mon Sep 17 00:00:00 2001 From: jasonweicn Date: Tue, 26 Jun 2018 17:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=A8=E5=B1=80=E5=87=BD?= =?UTF-8?q?=E6=95=B0getHash()=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=9C=A8=E5=88=86?= =?UTF-8?q?=E5=BA=93=E6=88=96=E5=88=86=E8=A1=A8=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=80=E4=B8=AA=E6=8C=87=E5=AE=9A=E9=95=BF?= =?UTF-8?q?=E5=BA=A6INT=E5=9E=8BHASH=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MiniFramework/Functions/Global.func.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MiniFramework/Functions/Global.func.php b/MiniFramework/Functions/Global.func.php index ae0f690..393658b 100644 --- a/MiniFramework/Functions/Global.func.php +++ b/MiniFramework/Functions/Global.func.php @@ -334,6 +334,7 @@ function isImage($file) /** * 获取字符串长度 + * * @param string $string * @return int */ @@ -344,6 +345,7 @@ function getStringLen($string) /** * 让浏览器下载文件 + * * @param string $file 文件路径 * @param string $customName 自定义文件名 * @return output | bool @@ -363,6 +365,7 @@ function browserDownload($file, $customName = null) /** * 获取文件扩展名 + * * @param string $filename * @return string */ @@ -372,3 +375,17 @@ function getFileExtName($filename) return $tmp[count($tmp) - 1]; } + +/** + * 获取一个指定长度INT类型HASH值 + * + * @param string $s + * @param number $len + * @return number + */ +function getHash($s, $len = 4) +{ + $h = sprintf('%u', crc32($s)); + + return intval(fmod($h, $len)); +}