一般在用验证码时我们都要实现局部刷新了,这个是必然的,也是提高用户体验的一点,下面我们来看一个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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools