php编程每天必学之验证码
发布时间:2020-12-12 21:21:39 所属栏目:PHP教程 来源:网络整理
导读:本文为大家分享了php图片验证码的实现代码,供大家参考研究具体内容如下 1.验证码图片生成 captcha.php //2.随机显示数字或字母 $captch_code = ""; for($i=0;$i4;$i++){ $fontsize=6; $fontcolor=imagecolorallocate($image,rand(0,120),120)); $da
本文为大家分享了php图片验证码的实现代码,分享给大家供大家参考,具体内容如下 1.验证码图片生成captcha.php//2.随机显示数字或字母
$captch_code = ""; for($i=0;$i<4;$i++){ $fontsize=6; $fontcolor=imagecolorallocate($image,rand(0,120),120)); $data = "abcdefghijkmnpqrstuvwxy3456789"; $fontcontent =substr($data,strlen($data)),1); $captch_code .=$fontcontent; $x = ($i*100/4)+rand(5,10); $y = rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); //3.增加干扰 //干扰线 header("content-type:image/png"); 2.页面实现验证码功能form.php?>
<!doctype html> |