//画画布$img = imagecreatetruecolor(100, 40);
//三种颜色$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);
$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
//填充白色
imagefill($img,0,0,$white);
//生成随机的验证码$code = '';
for($i = 0; $i 4; $i++) {
$code .= rand(0, 9);
}
imagestring($img, 5, 10, 10, $code, $black);
//加入噪点干扰for($i=0;$i50;$i++) {
imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black);
imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green);
}
//png输出验证码jpeg输出到当前文件夹
header("content-type: image/png");
imagepng($img);
imagejpeg($img, "./ok.jpeg", 75);
imagedestroy($img);
```//画画布$img = imagecreatetruecolor(100, 40);
//三种颜色$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);
$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
//填充白色
imagefill($img,0,0,$white);
//生成随机的验证码$code = '';
for($i = 0; $i 4; $i++) {
$code .= rand(0, 9);
}
imagestring($img, 5, 10, 10, $code, $black);
//加入噪点干扰for($i=0;$i50;$i++) {
imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black);
imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green);
}
//png输出验证码jpeg输出到当前文件夹
header("content-type: image/png");
imagepng($img);
imagejpeg($img, "./ok.jpeg", 75);
imagedestroy($img);
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介绍了php中利用gd图片验证码生成和保存,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
已抢66234个
抢已抢35398个
抢已抢19635个
抢