zoukankan      html  css  js  c++  java
  • php生成验证码

    $im = imagecreatetruecolor(100, 40);
    $white = imagecolorallocate($im,255, 255, 0);
    imagefill($im, 0, 0, $white);
    $color = imagecolorallocate($im, 0, 255, 255);
    imagerectangle($im, 1, 1,99,39, $color);

    $arr = "123456789asdfghjkertyuzxcvbnm";
    //echo strlen($arr);
    for($i = 0;$i<4;$i++){
      $char = $arr[rand(0,29)];
      $col = imagecolorallocate($im,rand(0,120),rand(0,120), rand(0,120));
      $x = ($i*100/4)+rand(5,10);
      $y = rand(10,20);
      imagestring ($im, 5, $x, $y ,$char, $col );

    }

    for($i = 0;$i<200;$i++){
      $x = rand(1,99);
      $y = rand(1,39);
      $c = imagecolorallocate($im,rand(0,120),rand(0,120), rand(0,120));
      imagesetpixel($im,$x,$y,$c);
    }

    for ($i=0; $i < 3; $i++) {
      $x1 = rand(1,99);
      $y1 = rand(1,39);
      $x2 = rand(1,99);
      $y2 = rand(1,39);
      $c = imagecolorallocate($im,rand(0,120),rand(0,120), rand(0,120));
      imageline ($im, $x1 , $y1 , $x2 , $y2 , $c );
    }
    header("content-type:image/jpg");
    imagejpeg($im);
    imagedestroy($im);

  • 相关阅读:
    变量数据类型
    c#变量小例子:模拟用户登入
    防盗监控系统小程序端
    java入门学习
    JAVA字符串处理函数汇总
    Freemarker学习
    监听器(Listener)
    正则表达式
    过滤器(Filter)
    HTML百宝箱(1从0开始)
  • 原文地址:https://www.cnblogs.com/liuwanqiu/p/5741898.html
Copyright © 2011-2022 走看看