网上生成php验证码程序用很多,下面我来给大家分享一款超不错的php验证码程序代码,有需要的朋友可参考,验证码识别一般分为以下几个步骤:1. 取出字模,2. 二值化,3. 计算特征,4. 对照样本.
php验证码程序代码如下:
<?php function _code($_code_length = 4, $_width = 75, $_height = 25) { for ($i = 0; $i < $_code_length; $i++) { $_nmsg.= dechex(mt_rand(0, 15)); } $_SESSION["code"] = $_nmsg; $_img = imagecreatetruecolor($_width, $_height); $_white = imagecolorallocate($_img, 250, 250, 250); imagefill($_img, 0, 0, $_white); $_gray = imagecolorallocate($_img, 196, 196, 196); imagerectangle($_img, 0, 0, $_width - 1, $_height - 1, $_gray); for ($i = 0; $i < 6; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(200, 255) , mt_rand(200, 255) , mt_rand(200, 255)); imageline($_img, mt_rand(0, $_width) , mt_rand(0, $_height) , mt_rand(0, $_width) , mt_rand(0, $_height) , $_md_color); } for ($i = 0; $i < 50; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(200, 255) , mt_rand(200, 255) , mt_rand(200, 255)); imagestring($_img, 1, mt_rand(1, $_width - 5) , mt_rand(1, $_height - 5) , "*", $_md_color); } for ($i = 0; $i < $_code_length; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(0, 102) , mt_rand(0, 102) , mt_rand(0, 102)); imagestring($_img, 5, $i * $_width / $_code_length + mt_rand(1, 10) , mt_rand(1, $_height / 2) , $_SESSION["code"][$i], $_md_color); } header("Content-Type:image/png"); imagepng($_img); imagedestroy($_img); } //验证码使用方法 $getcode = $_POST['code']; if ($_SESSION["code"] = $getcode) { echo ' 验证合法,进入下一步'; unset($_SESSION["code"]); } else { echo ' 验证码不正确'; header('location:vial.php'); }
本文地址:
转载随意,但请附上文章地址:-)
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
刺客信條陰影:貝殼謎語解決方案
3 週前ByDDD
Windows 11 KB5054979中的新功能以及如何解決更新問題
2 週前ByDDD
在哪裡可以找到原子中的起重機控制鑰匙卡
3 週前ByDDD
<🎜>:死鐵路 - 如何完成所有挑戰
4 週前ByDDD
Atomfall指南:項目位置,任務指南和技巧
1 個月前ByDDD

熱工具

Dreamweaver CS6
視覺化網頁開發工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3漢化版
中文版,非常好用