黑松山资源网 Design By www.paidiu.com
本文实例为大家分享了几段php验证码函数,都很实用,具体内容如下
代码段一:简单php验证码函数
<"content-type:image/png"); imagepng($im); } code() ; "color: #800000">php验证码函数function _code($_code_length = 4, $_width = 75, $_height = 25){ for($i=0;$i<$_code_length;$i++){ $_nmsg .= dechex(mt_rand(0,15)); } $_SESSION["code"] = $_nmsg; $_img = imagecreatetruecolor($_width, $_height); $_white = imagecolorallocate($_img, 250, 250, 250); imagefill($_img, 0, 0, $_white); $_gray = imagecolorallocate($_img, 196, 196, 196); imagerectangle($_img, 0, 0, $_width-1, $_height-1, $_gray); for ($i=0; $i < 6; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255)); imageline($_img, mt_rand(0,$_width), mt_rand(0, $_height),mt_rand(0,$_width), mt_rand(0, $_height), $_md_color); } for ($i=0; $i < 50; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255)); imagestring($_img, 1, mt_rand(1,$_width-5), mt_rand(1, $_height-5), "*", $_md_color); } for ($i=0; $i < $_code_length ; $i++) { $_md_color = imagecolorallocate($_img, mt_rand(0,102), mt_rand(0,102), mt_rand(0,102)); imagestring($_img, 5, $i * $_width/$_code_length+ mt_rand(1, 10), mt_rand(1, $_height/2), $_SESSION["code"][$i], $_md_color); } header("Content-Type:image/png"); imagepng($_img); imagedestroy($_img); }代码段三:php图片验证码函数
/*@ captcha()函数的功能:生成验证码 * @ 可自定义参数: * @ $width 图片宽度,默认80 * @ $high 高度,默认25 * @ $num 验证码个数,默认4个 * @ $line_num 随机画线条的个数,默认10 * @ $snow_num 随机雪花的数量,默认50 */ function captcha($width=80,$high=25,$num=4,$line_num=10,$snow_num=50){ header('Content-Type:image/png'); session_start(); //生成随机数字+字母 for($a = 0;$a < $num;$a++){ $code .= dechex(mt_rand(0, 15));//dechex — 十进制转换为十六进制 } //把生成的验证码保存在SESSION超级全局数组中 $_SESSION['captcha'] = $code; //创建画布 $img = imagecreatetruecolor($width,$high); //填充背景色为白色 $backcolor = imagecolorallocate($img, '255', '255', '255'); imagefill($img, '0', '0', $backcolor); //添加黑色边框 $bordercolor = imagecolorallocate($img, 0, 0, 0); imagerectangle($img, 0, 0, $width-1, $high-1, $bordercolor); //随机画线条 for($i=0;$i<$line_num;$i++){ imageline($img, mt_rand(0, $width*0.1), mt_rand(0, $high), mt_rand($width*0.9, $width), mt_rand(0, $high), imagecolorallocate($img, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255))); } //随机打雪花 for ($i=0;$i<$snow_num;$i++){ imagechar($img,1, mt_rand(0, $width), mt_rand(0, $high),'*', imagecolorallocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255))); } //画验证码 for ($b = 0;$b < strlen($_SESSION['captcha']);$b++){ imagechar($img,5, $b*$width/$num+mt_rand(5,10), mt_rand(2, $high/2),$_SESSION['captcha'][$b], imagecolorallocate($img, mt_rand(10, 150), mt_rand(10, 150), mt_rand(0, 100))); } ob_clean();//清空输出缓冲区 imagepng($img); imagedestroy($img); }以上就是三段参考性较高的php验证码函数,希望对大家学习php程序设计有所帮助。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2025年03月04日
2025年03月04日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]