From 50f804c3f307935f13f5e704cb260fdec74c3c42 Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Sun, 10 May 2020 20:50:30 +0800 Subject: [PATCH] test --- test.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test.php b/test.php index fcdb5f2..c7eb7f1 100644 --- a/test.php +++ b/test.php @@ -28,10 +28,24 @@ //$s2 = "dotcoo"; //$s3 = "hello dotcoo"; //var_dump(substr($s1, -strlen($s2)) === $s2); -function insert($sql, $db_conn = null, $types = null, ...$_) -{ - var_dump($types); +/* + * 生成随机字符串 + * @param int $length 生成随机字符串的长度 + * @param string $char 组成随机字符串的字符串 + * @return string $string 生成的随机字符串 + */ +function str_rand($length = 32, $char = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { + if(!is_int($length) || $length < 0) { + return false; + } + + $string = ''; + for($i = $length; $i > 0; $i--) { + $string .= $char[mt_rand(0, strlen($char) - 1)]; + } + + return $string; } -insert("123", $types = "ffff"); +var_dump(str_rand(5));