欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-23 18:03:17
...

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; ++ ((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; ++
imageline(, 0, (0, 20), (70,100), (0, 20),  = imagecolorallocate(, (0, 255),(0, 255),(0, 255
(=0; ++, (1, 100), (1, 30), 
("Content-type: image/jpeg"
imagejpeg(?>


(@['check'(["check"] == ["check"" 恭喜你!验证码输入正确!"" 不好意思验证码输入错误"?>
PHP5 GD库生成图形验证码(汉字)_PHP教程

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440246.htmlTechArticle1,利用GD库函数生成图片,并在图片上写指定字符 imagecreatetruecolor 新建一个真彩色图像 imagecolorallocate 为一幅图像分配颜色(调色板) images...