# captcha **Repository Path**: xxg3053/captcha ## Basic Information - **Project Name**: captcha - **Description**: 使用PHP创建验证码 - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-10-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # captcha 使用PHP创建验证码 git: https://gitee.com/xxg3053/captcha 学习:http://www.imooc.com/learn/115 ## 实现简单的验证码 1. 生成一张100*30px大小的图片 ``` resource imagecreatetruecolor(int $width, int $height) ``` ## 在底图上生成随机数 方法: ``` int imagecolorallocate bool imagesting ``` ## 增加点干扰元素 ``` imagesetpixel ``` ## 增加线干扰元素 ``` imageline ``` ## 换一个 ``` document.getElementById('captcha_img').src='./captcha.php?r='+Math.random() ``` ## 图片验证码 ``` $table = array( 'pic0'=>'狗', 'pic1'=>'猫', 'pic2'=>'鱼', 'pic3'=>'鸟' ); ``` ## 汉字验证码 依赖GD库中的imagettftext() gbk编码时需要将中文通过iconv()转换为utf-8 选用的ttf文件需要支持中文 ## 复杂验证码 ![image](http://7xky7l.com1.z0.glb.clouddn.com/captcha.jpg)