-
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);
-
相关阅读:
数据分析 --- 01. Numpy
爬虫 --- 08. 全站爬取(CrawlSpider), 分布式, 增量式爬虫
爬虫 --- 07. 全站爬取(手动), post请求,cookie, 传参,中间件,selenium
数据结构 --- 02. 内存, 顺序表, 单链表
数据结构 --- 01. 时间复杂度,timeit模块,栈,队列,双端队列
爬虫 --- 06. scrapy框架初始,移动端数据爬取
爬虫 --- 05. 异步协程, 浏览器自动化,
爬虫 --- 04. 代理服务器, 验证码识别, 处理cookie,线程池
爬虫 --- 02. 爬取图片,数据解析
一个关于const 变量作为map键值的Bug
-
原文地址:https://www.cnblogs.com/lijiageng/p/5800830.html
Copyright © 2020-2023
润新知