php验证码的简单例子

php随机验证码:
<?php
     $image_width=140;
     $image_height=50;
     srand(microtime()*10000);
     for($i=0;$i<4;$i++){
              $number.=dechex(rand(0,15));
            }
    $check=$number;
    $im=imagecreate($image_width,$image_height);
    imagecolorallocate($im,255,255,255);
    for($i=0;$i<strlen($check);$i++){
        $font=rand(40,80);
        $x=rand(1,8)+$image_width*$i/4;
        $y=rand(1,$image_height/4);
        $color=imagecolorallocate($im,rand(0,100),rand(0,150),rand(0,200));
        imagestring($im,$font,$x,$y,$check[$i],$color);
        }
        imagepng($im);

        imagedestroy($im);
?>
原文地址:https://www.cnblogs.com/linuxnotes/p/3472350.html