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

     1 function _code($_code_length = 4, $_width = 75, $_height = 25){
     2     for($i=0;$i<$_code_length;$i++){
     3         $_nmsg .= dechex(mt_rand(0,15));
     4     }
     5     $_SESSION["code"] = $_nmsg;
     6 
     7     $_img = imagecreatetruecolor($_width, $_height);
     8 
     9     $_white = imagecolorallocate($_img, 250, 250, 250);
    10 
    11     imagefill($_img, 0, 0, $_white);
    12 
    13     $_gray = imagecolorallocate($_img, 196, 196, 196);
    14 
    15     imagerectangle($_img, 0, 0, $_width-1, $_height-1, $_gray);
    16 
    17     for ($i=0; $i < 6; $i++) { 
    18         $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255));
    19         imageline($_img, mt_rand(0,$_width), mt_rand(0, $_height),mt_rand(0,$_width), mt_rand(0, $_height), $_md_color);
    20     }
    21 
    22     for ($i=0; $i < 50; $i++) { 
    23         $_md_color = imagecolorallocate($_img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255));
    24         imagestring($_img, 1, mt_rand(1,$_width-5), mt_rand(1, $_height-5), "*", $_md_color);
    25     }
    26 
    27     for ($i=0; $i < $_code_length ; $i++) { 
    28         $_md_color = imagecolorallocate($_img, mt_rand(0,102), mt_rand(0,102), mt_rand(0,102));
    29         imagestring($_img, 5, $i * $_width/$_code_length+ mt_rand(1, 10), mt_rand(1, $_height/2), $_SESSION["code"][$i], $_md_color);
    30     }
    31 
    32     header("Content-Type:image/png");
    33 
    34     imagepng($_img);
    35 
    36     imagedestroy($_img);
    37 }
  • 相关阅读:
    汇编写启动代码之关看门狗、设置栈、调用C、开关icache
    ARM汇编伪指令
    多寄存器访问、后缀、栈、!、^
    协处理器CP15操作指令
    常用的ARM指令
    汇编指令及其特点
    ARM的37个寄存器以及异常处理方法
    一步步点亮LED之汇编点亮LED
    机器学习_第一节_numpy
    函数进阶_生成器
  • 原文地址:https://www.cnblogs.com/nghygaojun/p/3078952.html
Copyright © 2011-2022 走看看