<?php /** * Created by PhpStorm. * User: Administrator * Date: 2017\10\10 0010 * Time: 19:44 */ //生成随机验证码 $strNumber = join('',range(0,9)); $strChar = join('',range('a','z')); $str = $strNumber.$strChar.strtoupper($strChar); $str = substr(str_shuffle($str),'0',4); header("Content-type: p_w_picpath/png"); //创建画布 $width = 100; $height = 50; $p_w_picpath = p_w_picpathcreate($width,$height); //创建颜色 $bgcolor = p_w_picpathcolorallocate($p_w_picpath,rand(0,20),rand(0,20),rand(0,20)); //备用颜色(干扰线) $colorone = p_w_picpathcolorallocate($p_w_picpath,rand(100,155),rand(200,155),rand(100,155));; //干扰线 for($j=0; $j<10; $j++){ p_w_picpathline($p_w_picpath, rand(0,$width), rand(0,$height-20), rand(0,$width), rand(0,$height), $colorone); } //循环添加字符到画布 每个字符的坐标为(总宽度 / 验证码的个数) for($i=0; $i<4; $i++){ //备用颜色(文字) $fontcolor= p_w_picpathcolorallocate($p_w_picpath,rand(0,255),rand(100,200),rand(180,255)); $x = (($width / 4) * $i) + $width / 10; $y = rand(10,$height-20); p_w_picpathchar($p_w_picpath, 5, $x, $y,$str[$i], $fontcolor); } p_w_picpathpng($p_w_picpath); p_w_picpathdestroy($p_w_picpath);
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。