php的验证码要gd库,PHP利用GD库实现一个简单的验证码
搜索熱詞
下面是編程之家 jb51.cc 通過網絡收集整理的代碼片段。
編程之家小編現在分享給大家,也給大家做個參考。
$img=imagecreatetruecolor(100,40);
$red=imagecolorallocate($img,255,0);
$green=imagecolorallocate($img,0);
$blue=imagecolorallocate($img,255);
$white=imagecolorallocate($img,255);
$black=imagecolorallocate($img,0);
//生成圖片
imagefill($img,$black);
//設置驗證碼
$code="";
for($i=0;$i<5;$i++){
$code.=rand(0,9);
}
//驗證碼寫到圖片中
imagestring($img,5,20,15,$code,$white);
//加點兒干擾
for($i=0;$i<10;$i++){
imagesetpixel($img,rand(0,100),40),$red);
imagesetpixel($img,$green);
imagesetpixel($img,$blue);
}
//再加點兒干擾
for($i=0;$i<1;$i++){
imageline($img,50),20),rand(50,rand(20,$red);
imageline($img,$green);
imageline($img,$blue);
}
header("Content-type:image/png");
imagepng($img);
imagedestroy($img);
?>
以上是編程之家(jb51.cc)為你收集整理的全部代碼內容,希望文章能夠幫你解決所遇到的程序開發問題。
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
總結
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
本圖文內容來源于網友網絡收集整理提供,作為學習參考使用,版權屬于原作者。
總結
以上是生活随笔為你收集整理的php的验证码要gd库,PHP利用GD库实现一个简单的验证码的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: D - 卿学姐与魔法
 - 下一篇: [JSOI2008]最小生成树计数