• php验证码


    <?php
    session_start();
    $width=50;
    $height=22;
    $img=imagecreatetruecolor($width,$height);
    $times=4;
    //$arr1=range("a","z");
    $arr2=range(0,9);
    //$arr3=range("A","Z");
    //$arr=array_merge($arr1,$arr2,$arr3);
    $arr=array_merge($arr2);
    $keys=array_rand($arr,$times);
    $str="";
    foreach($keys as $i)
    $str.=$arr[$i];
    $_SESSION["randValid"]=$str;
    for($i=0;$i<$times*2;$i++)
    {
    $color=imagecolorallocate($img,rand(0,156),rand(0,156),rand(0,156));//干扰像素颜色
    imageline($img,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);
    $color=imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));
    imagesetpixel($img,rand(0,$width),rand(0,$height),$color);
    }
    $color=imagecolorallocate($img,255,255,255);
    imagestring($img,5,5,3,$str,$color);
    header("content-type:image/png");
    imagepng($img);
    imagedestroy($img);
    ?>

  • 相关阅读:
    java集合的简单用法
    数据结构
    数据结构
    数据结构
    数据结构
    软件工程第三次作业
    软件工程第三次作业
    软件工程第三次作业
    软件工程第三次作业
    Linux 开发之线程条件锁那些事
  • 原文地址:https://www.cnblogs.com/something/p/2729258.html
Copyright © 2020-2023  润新知