验证码实现php 难点,php实现简单的验证码功能
生活随笔
收集整理的這篇文章主要介紹了
验证码实现php 难点,php实现简单的验证码功能
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
php實現簡單的驗證碼功能<?php
//簡單的驗證碼
//隨機數
//為什么要循環0-15之間的數呢?
//因為要實現最簡單的字母和數字混搭
//十六進制0-9?a-f
//dechex?--?十進制轉換為十六進制
//創建一個四位的驗證碼
$nmsg?=?'';
for?($i=0;$i<4;$i++)?{
$nmsg?.=?dechex(mt_rand(0,15));
}
header('Content-Type:?image/png');
$im?=?imagecreatetruecolor(75,25);
$blue?=?imagecolorallocate($im,0,102,255);
$white?=?imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$blue);
imagestring($im,5,20,5,$nmsg,$white);
imagepng($im);
imagedestroy($im);
Tags:
總結
以上是生活随笔為你收集整理的验证码实现php 难点,php实现简单的验证码功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 批量删除cookie,php批量
- 下一篇: oracle as sydba,orac