一般在用验证码时我们都要实现局部刷新了,这个是必然的,也是提高用户体验的一点,下面我们来看一个php验证码在实际应用中的用法,有需要的朋友来参考一下。
/*
* Auth_code()是验证码函数
* @access public
* @param int $width 表示验证码的长度,默认为80
* @param int $height 表示验证码的高度,默认为20
* @param int $num 表示验证码中数字位数,默认为4
* @param int $line 表示验证码中线的条数,默认为4
* @param int $line 表示验证码中点的个数,默认为150
*/
代码如下 | 复制代码 |
function Auth_code($width = 80,$height = 20,$num = 4,$line = 4,$dot = 150) { $length = floor($width/$num); //floor:取整数部分 length:每段平均长度 |
-主要函数:
imagecreatetruecolor //新建一个黑色底的画板
imagecolorallocate //取色
imagefill //填充画板
imageline //画线
imagesetpixel //画点
imagestring //画字符串(本验证码为数字)
注意:在将数字验证码画上画板时要注意字体越界,所以要相应减去一些范围,详见附件。
-局部刷新验证码:
代码如下 | 复制代码 |
![]() |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
