PHP--中文验证码
来源:互联网 发布:软件培训中心 编辑:程序博客网 时间:2024/04/27 23:33
01.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***图片里写中文,并做中文验证码array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )***/// 创建画布$im = imagecreatefromjpeg('./home.jpg');// 创建颜料$blue = imagecolorallocate($im,0,0,255);// 写字imagettftext($im,25,30,327,157,$blue,'./msyh.ttf','加州水郡');// 输出或保存header('content-type: image/jpeg');imagejpeg($im);// 销毁imagedestroy($im);
02.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***====笔记部分====中文验证码如何产生随机的中文字符串?中文按其unicode编码,是有规律的,位于0x4E00-0x9FA0我们可以在uncode范围内随机选取,但是 请注意,对于用户来说,能否认得?因为有大量生僻字.所以在实际项目中,只是抽取几百或上千个常用汉字,放数组里,随机选取.***/$char = array('中','华','人','民','共','和','国');shuffle($char);$code = implode('',array_slice($char,0,4));// 画布$im = imagecreatetruecolor(65,25);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);// 填充imagefill($im,0,0,$gray);// 写字imagettftext($im,12,0,2,20,$blue,'./msyh.ttf',$code);// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***====笔记部分====画复杂图形,并填充矩形椭圆圆弧(统计时的饼状图,要用到)***/// 画布$im = imagecreatetruecolor(800,600);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);$red = imagecolorallocate($im,255,0,0);// 填充imagefill($im,0,0,$gray);// 画一个矩形/*bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )参数: 画布资源, 左上角x坐标,左上y坐标,右下x坐标,右下y坐标,颜色*/imagerectangle($im,200,150,600,450,$blue);// 画椭圆/*bool imageellipse ( resource $image , int $cx , int $cy , int $w , int $h , int $color )参数:画布资源,圆心x坐标,圆心y坐标,宽,高,颜色*/imageellipse ( $im , 400 , 300 , 400 , 300 , $red );imageellipse ( $im , 400 , 300 , 300 , 300 , $red );imageellipse ( $im , 400 , 300 , 200 , 300 , $red );imageellipse ( $im , 400 , 300 , 100 , 300 , $red );// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
04.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***====笔记部分====画复杂图形,并填充矩形椭圆圆弧(统计时的饼状图,要用到)***/// 画布$im = imagecreatetruecolor(800,600);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);$red = imagecolorallocate($im,255,0,0);// 填充imagefill($im,0,0,$gray);// 画一个矩形并填充/*bool imagefilrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )参数: 画布资源, 左上角x坐标,左上y坐标,右下x坐标,右下y坐标,颜色*/imagefilledrectangle($im,200,150,600,450,$blue);// 画椭圆并填充/*bool imagefilledellipse ( resource $image , int $cx , int $cy , int $w , int $h , int $color )参数:画布资源,圆心x坐标,圆心y坐标,宽,高,颜色*/imagefilledellipse ( $im , 400 , 300 , 400 , 300 , $red );imagefilledellipse ( $im , 400 , 300 , 300 , 300 , $blue );imagefilledellipse ( $im , 400 , 300 , 200 , 300 , $red );imagefilledellipse ( $im , 400 , 300 , 100 , 300 , $blue );// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
05.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***====笔记部分====画饼图其实就是画圆弧***/// 画布$im = imagecreatetruecolor(800,600);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);$red = imagecolorallocate($im,255,0,0);// 填充imagefill($im,0,0,$gray);/*画一段圆弧bool imagearc ( resource $image , int $cx , int $cy , int $w , int $h , int $s , int $e , int $color )参数为: 画布,圆心x值,圆心y值,宽,高,起始角度,结果角度,颜色*/imagearc($im,400,300,300,300,270,0,$blue);imagearc($im,400,300,310,310,-90,0,$red);// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
06.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//***====笔记部分====画饼图画圆弧并填充***/// 画布$im = imagecreatetruecolor(800,600);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);$red = imagecolorallocate($im,255,0,0);// 填充imagefill($im,0,0,$gray);/*画一段圆弧并填充bool imagefilledarc ( resource $image , int $cx , int $cy , int $w , int $h , int $s , int $e , int $color , int $style )参数为: 画布,圆心x值,圆心y值,宽,高,起始角度,结果角度,颜色,填充方式1 IMG_ARC_CHORD 直线连圆弧2端0 IMG_ARC_PIE 弧线连圆弧2端4 IMG_ARC_EDGED 指明用直线将起始和结束点与中心点相连,2 IMG_ARC_NOFILL 不填充轮廓(默认是填充的)*/imagefilledarc($im,400,300,300,300,270,0,$blue,1+2+4);imagefilledarc($im,0,400,310,310,0,45,$blue,0+4);imagefilledarc($im,0,400,300,300,0,45,$red,0+4);// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
07.php
<?php/****燕十八 公益PHP讲堂论 坛: http://www.zixue.it微 博: http://weibo.com/YshibaYY频道: 88354001****//*imagefill的用法*/// 画布$im = imagecreatetruecolor(800,600);// 颜料$gray = imagecolorallocate($im,200,200,200);$blue = imagecolorallocate($im,0,0,255);$red = imagecolorallocate($im,255,0,0);// 填充imagefill($im,200,200,$gray);imageellipse($im,400,300,300,300,$blue);// 再次填充imagefill($im,400,300,$red);// 输出header('content-type: image/jpeg;');imagejpeg($im);//销毁imagedestroy($im);
0 0
- PHP--中文验证码
- php中文验证码
- PHP中文汉字验证码
- php 生成中文验证码
- PHP 中文图形验证码
- php——记中文验证码
- PHP正则验证中文
- php中文用户名验证代码
- php 之 简单中文验证
- php中文汉字正则验证
- PHP制作数字字母混合验证码、图片验证码、中文验证码
- PHP汉字验证码中文乱码之解决方法
- 在PHP中实现中文汉字验证码
- PHP 中文验证码不能正确显示的解决方案
- php中文字母数字验证码实现代码
- 还是php验证中文的问题
- PHP正则表达式验证是否含有中文
- PHP 正则表达式验证中文的问题
- WebService 学习笔记之一 HelloWorld
- java keytool 使用总结
- android手机root后的安全问题 (一)
- VS2013常用快捷键
- Interleaving String
- PHP--中文验证码
- 八皇后
- 重力感应4个方向都可以旋转
- CI前后台多目录搭建管理
- 平衡生活和工作
- 新
- android手机root后的安全问题 (二)
- 【Android】Activity onSaveInstanceState onPause之前(<3.0) onStop之前(3.0<=)
- 正则表达变化内容