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);

  • 相关阅读:
    单例模型
    数据库7 索引
    数据库6.高级
    数据库5 不想改
    绑定方法与非绑定方法 反射 内置方法
    组合 封装 多态
    面向对象之继承
    面向过程编程
    logging hashlib 模块
    pickle json xml shelve configparser模块
  • 原文地址:https://www.cnblogs.com/liuwanqiu/p/5741898.html
Copyright © 2011-2022 走看看