panqihua 5 years ago
parent c1948a44dc
commit 50f804c3f3
  1. 22
      test.php

@ -28,10 +28,24 @@
//$s2 = "dotcoo"; //$s2 = "dotcoo";
//$s3 = "hello dotcoo"; //$s3 = "hello dotcoo";
//var_dump(substr($s1, -strlen($s2)) === $s2); //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;
} }
insert("123", $types = "ffff"); $string = '';
for($i = $length; $i > 0; $i--) {
$string .= $char[mt_rand(0, strlen($char) - 1)];
}
return $string;
}
var_dump(str_rand(5));

Loading…
Cancel
Save