爱程序网

php 实现验证码制作

来源: 阅读:

先给看下 大致的效果

那么接下来的就直接贴代码吧

<?php        $image = imagecreatetruecolor(100, 30); //创建画布        $imagecolor = imagecolorallocate($image, 255, 255, 255);  //背景色        imagefill($image, 0, 0, $imagecolor);  //填充背景色        for($i=0;$i<4;$i++ ){                  //循环4位数                $fontsize = 6;        $fontcolor = imagecolorallocate($image, rand(0, 200), rand(0, 200), rand(0, 200));        $fontcontent = rand(0, 9);                $x = $i*100/4 + rand(5, 15);        $y = rand(5, 10);