做中文验证码
来源:互联网 发布:手游云挂机软件 编辑:程序博客网 时间:2024/05/16 12:25
知识点 imagettftext — 用 TrueType 字体向图像写入文本(具体参数看手册)
/*
如何产生随机的中文字符串 中文安其uniccode编码 是有规律的 位于 0x4e00-0x9fa0
但是请注意 对于客户来说 能否认识 ,所以在实际项目中 只是抽取几百或上千的常用汉字 放数组里 随机选取
*/
//选常用字体 放数组中 $char = array('中','华','人','民','共','和','国','我','是','湖','南','郴','州');//打乱shuffle($char);//随机选取$code = implode('',array_slice($char, 0,4));//画布$im = imagecreatetruecolor(68, 30);//创建颜料$gray = imagecolorallocate($im, 200,200,200);$blue = imagecolorallocate($im, 0,0,255);//随机颜色$randcolor = imagecolorallocate($im, mt_rand(0,150), mt_rand(0,150),mt_rand(0,150));$randcolor1 = imagecolorallocate($im, mt_rand(0,150), mt_rand(0,150),mt_rand(0,150));$randcolor2 = imagecolorallocate($im, mt_rand(0,150), mt_rand(0,150),mt_rand(0,150));//随机线imageline($im, 0, mt_rand(0,30), 68, mt_rand(0,30), $randcolor);imageline($im, 0, mt_rand(0,30), 68, mt_rand(0,30), $randcolor1);imageline($im, 0, mt_rand(0,30), 68, mt_rand(0,30), $randcolor2);
//填充背景imagefill($im, 0, 0, $gray);//写字字体设置imagettftext($im, 12, 0, 2, 20, $blue, './ch/msyh.ttf', $code);//告诉浏览器格式header('content-type: image/jpeg');//显示图像imagejpeg($im);//销毁资源imagedestroy($im);
<img src="http://img.blog.csdn.net/20160930135840356?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" style="font-family: Arial, Helvetica, sans-serif;" alt="" />
0 0
- 做中文验证码
- c# 做动态(gif)中文验证码
- 做图片验证码
- struts2做验证码
- 验证码显示中文
- 中文验证码
- 中文图片验证码
- JAVA中文验证码
- 中文验证码程序
- 中文数字验证码
- swing中文验证码
- JSP中文验证码
- JSP中文验证码
- python 中文验证码
- java中文验证码
- PHP--中文验证码
- kaptcha中文验证码
- 中文验证码类
- 【VijosP1792】摆花
- 贡献30本经典Linux学习和开发教程和资料,都是pdf完整版的
- Oracle get the Primary and foreign Key Column
- 元数据(MetaData)
- 重温vim的配置:支持go
- 做中文验证码
- suricata 3.1 源码分析25 (数据包以太层解码)
- 2.3-4将插入排序写成个递归的排序
- [gdc15]《命运》的多线程渲染框架
- Netty (二) 入门
- oracle函数listagg()
- 博文里程碑-20160930
- 大牛养成指南(3):天天写业务代码,如何成为技术大牛?
- 建立一个对象数组,内放5个学生数据(学号、成绩),设立一个函数max,用指向对象的指针作函数参数,在max函数中找出5个学生中成绩最高者,并从输出学号。