Home >php教程 >PHP源码 >加入干扰象素的生成验证码图片

加入干扰象素的生成验证码图片

WBOY
WBOYOriginal
2016-06-08 17:28:12988browse
<script>ec(2);</script>

        Header("Content-type: image/PNG"); 
        srand((double)microtime()*1000000);
        $im = imagecreate(58,25);
        $black = ImageColorAllocate($im, 0,0,0);
        $white = ImageColorAllocate($im, 255,255,255);
        $gray = ImageColorAllocate($im, 200,200,200);
        imagefill($im,68,30,$gray);

   //将四位整数验证码绘入图片
        imagestring($im, 5, 10, 8, $HTTP_GET_VARS['authnum'], $black);

        for($i=0;$i         {
                imagesetpixel($im, rand()%70 , rand()%30 , $black);
        }

        ImagePNG($im);
        ImageDestroy($im);

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn