<?php //运用PHP画图手艺,画出本身的验证码 $checkCode=""; for($i=0;$i<4;$i++){ //dechex把一个十进制数转换成十六进制 $checkCode.=dechex(rand(1,15)); } //存入到session session_start(); $_SESSION['checkcode']=$checkCode; //建立画布 $image1=imagecreatetruecolor(110,30); //建立色彩 $white=imagecolorallocate($image1,255,255,255); //绘制字符 imagestring($image1,rand(1,5),rand(0,80),rand(0,20),$checkCode,$white); //画出滋扰线 //建立滋扰线随机色彩 for($i=0;$i<20;$i++){ $randomColor=imagecolorallocate($image1,rand(0,255),rand(0,255),rand(0,255)); imageline($image1,rand(0,110),rand(0,30),rand(0,110),rand(0,30),$randomColor); } //输出 header("content-type:image/png"); imagepng($image1); //烧毁图片 imagedestroy($image1); ?>
图片情势是如许的
相干教程:PHP视频教程
以上就是如何用PHP言语绘制多样字符验证码的细致内容,更多请关注ki4网别的相干文章!