验证码,是一种区分用户是计算机和人的公共全自动程序,在captcha测试中,作为服务器的计算机会自动生成一个问题由用户来解答,这个问题可以由计算机生成并评判,但是必须只有人类才能解答,由于计算机无法解答captcha的问题,所以回答出问题的用户就可以被认为是人类,php实例代码如下:
<?php session_start(); $string = null; $im = imagecreatetruecolor(60, 25); //创建真彩图60*25 $bg = imagecolorallocate($im, 255, 255, 255); //白色背景 imagefill($im, 0, 0, $bg); //填充白色 $x = 5; // $y = 0; //文字坐标 for ($i = 0; $i & lt; 4; $i++) { $char = mt_rand(0, 9); $string.= $char; $y = mt_rand(0, 10); $ccolor = imagecolorallocate($im, mt_rand(0, 230) , mt_rand(0, 230) , mt_rand(0, 230)); imagechar($im, 6, $x, $y, $char, $ccolor); //填充文字 $x+= mt_rand(10, 15); } for ($i = 0; $i{$x1 = mt_rand(0, 80); $x2 = mt_rand(0, 80); $y1 = mt_rand(0, 30); $y2 = mt_rand(0, 30); $x2 = $x1 + mt_rand(1, 5); $y2 = $y1 + mt_rand(1, 5); $lc = imagecolorallocate($im, mt_rand(0, 230) , mt_rand(0, 230) , mt_rand(0, 230)); imageline($im, $x1, $y1, $x2, $y2, $lc); //填充线条 }$_session['code'] = md5($string); header("content-type:image/jpeg"); imagepng($im); imagedestroy($im);
永久地址:
转载随意~请带上教程地址吧^^
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
1 months agoByDDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
1 months agoByDDD
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks agoByDDD

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version
