用PHP制作简单的图片验证码

来源:互联网 发布:熊猫tv抢竹子软件 编辑:程序博客网 时间:2024/04/30 00:26
//start session at the very beginningsession_start();//生成4个随机数$rand1 = '';for($i = 0; $i < 4; $i++){$rand1 .= dechex(rand(0,15));}//save the random number to session$_SESSION['check_pic'] = $rand1;//创建图像区域$im = imagecreatetruecolor(100, 30);//set color$bg = imagecolorallocate($im, 0, 0, 0);$te = imagecolorallocate($im, 255, 255, 255);//write the string on the imageimagestring($im, rand(3,6), rand(3, 70), rand(3,15), $rand1, $te);//output as imageheader("Content-type:image/jpeg");imagejpeg($im);