PHP头条
热点:

PHP5 GD库生成图形验证码(汉字)


1,利用GD库函数生成图片,并在图片上写指定字符
imagecreatetruecolor 新建一个真彩色图像
imagecolorallocate 为一幅图像分配颜色(调色板)
imagestring 绘制字符
imageline 绘制线条
imagesetpixel 打像素点
2,输出图片
imagejpeg($img);
PHP实现过程,代码中注释详细,这里不做过多解释
verify.php

<?

 = ("GBK", "utf-8", "芸芸众生绿水青山名胜古迹敞开心胸便会云蒸霞蔚快乐将永远伴随着你"(!() || !mb_check_encoding(,"utf-8"("不是字符串或者不是utf-8"
 = mb_strlen(,"UTF-8"
 = ( =0; <; ++[] = mb_substr(, ,1,"UTF-8" = ""
(=0; <4; ++ ((0, 1 0:
.=[(0, -1 1:
.=((0,15["check"] = 
 = imagecreatetruecolor(100, 30
 = imagecolorallocate(, 0, 0, 0
 = imagecolorallocate(, 255,255,255
imagettftext(, 13, (2, 9), 20 ,20, , "MSYH.TTF",["check"] = (=0; <3; ++
imageline(, 0, (0, 20), (70,100), (0, 20),  = imagecolorallocate(, (0, 255),(0, 255),(0, 255
(=0; <200; ++, (1, 100), (1, 30), 
("Content-type: image/jpeg"
imagejpeg(?>

<?
(@['check'(["check"] == ["check"" 恭喜你!验证码输入正确!"" 不好意思验证码输入错误"?>
<form action="" method="post">
<img src="verify.php"/> </br>
<input type="text" name="check"></br>
<input type="submit" value="submit"></br>
</form>

www.phpzy.comtrue/php/2955.htmlTechArticlePHP5 GD库生成图形验证码(汉字) 1,利用GD库函数生成图片,并在图片上写指定字符 imagecreatetruecolor 新建一个真彩色图像 imagecolorallocate 为一幅图像分配颜色(调色板) imagestring 绘制字符 i...

相关文章

相关频道:

PHP之友评论

今天推荐