-
php 生成 验证码的例子
- /**
- +----------------------------------------------------------
- * 生成随机字符串 CuPlayer.com 酷播
- +----------------------------------------------------------
- * @param int $length 要生成的随机字符串长度
- * @param string $type 随机码类型:0,数字+大小写字母;1,数字;2,小写字母;3,大写字母;4,特殊字符;-1,数字+大小写字母+特殊字符
- +----------------------------------------------------------
- * @return string
- +----------------------------------------------------------
- */
- function randCode($length = 5, $type = 0) {
- $arr = array(1 => "0123456789", 2 => "abcdefghijklmnopqrstuvwxyz", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4 => "~@#$%^&*(){}[]|");
- if ($type == 0) {
- array_pop($arr);
- $string = implode("", $arr);
- } elseif ($type == "-1") {
- $string = implode("", $arr);
- } else {
- $string = $arr[$type];
- }
- $count = strlen($string) - 1;
- $code = '';
- for ($i = 0; $i < $length; $i++) {
- $code .= $string[rand(0, $count)];
- }
- return $code;
- }
-
- echo randCode(6,1);
-
相关阅读:
求欧拉回路的算法学习
2020牛客暑期多校训练营(第六场 )C Combination of Physics and Maths(思维)
2020牛客暑期多校训练营(第六场)E.Easy Construction(思维构造,附图解)
CF1038D Slime(思维+枚举+贪心)(来自洛谷)
CF1250B The Feast and the Bus(贪心+枚举)(来自洛谷)
Codeforces Round #659 (Div. 2) A.Common Prefixes
IDEA本人亲测可用的破解方法
Codeforces Round #658 (Div. 2)(A,B博弈,C1,C2)
2020牛客暑期多校训练营(第四场)B.Basic Gcd Problem(数学)
2020牛客暑期多校训练营(第三场)B.Classical String Problem(思维)
-
原文地址:https://www.cnblogs.com/lijiageng/p/5800830.html
Copyright © 2020-2023
润新知