• 2014-05-14 总结


    PHP 验证码(补充)

    1、改变验证码背景颜色:imagefill(图片,填充的宽,填充的高,颜色)

           $back = imagecolorallocate($img,194,219,255);        imagefill($img,0,0,$back);

    2、字体颜色随机改变:rand(0,255)

          $color = imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));

    3、生成文字的位置不同:    

        $fwx=rand(6,30);   

        for($i=0;$i<4;$i++){   

        $fwy=rand(2,15);   

        imagestring($img,rand(2,5),$fwx,$fwy,substr($rand,$i,1),$color);   

        $fwx+=rand(8,20);

        }

    4、生成干扰线: imageline(图片,起始x位置,起始y位置,结束x位置,结束y位置,颜色);

         $ganraox1=rand(6,30);     

         $ganraox2=rand(30,60);     

         for($i=0;$i<4;$i++){          

         $ganraoy1=rand(2,20);          

         $ganraoy2=rand(8,30);        

          imageline       ($img,$ganraox1,$ganraoy1,$ganraox2,$ganraoy2,$color);          

          $ganraox1+=rand(30,60);          

          $ganraox2+=rand(61,98);    

         }

    5、生成干扰点:

            for($i=0;$i<100;$i++){            imagesetpixel($img,rand(2,100),rand(2,30),$color);        }

    PHP 函数封装

    6、连接数据库

          define("HOST","127.0.0.1");
          define("USER","root");
          define("PWD","");
          $conn = "";
          function get_conn(){
             global $conn;
             $conn = mysql_connect(HOST,USER,PWD) or die(mysql_error());
             mysql_select_db("test",$conn);
             mysql_query("set names 'utf8'");
    }

          

  • 相关阅读:
    TypeScript reflect-metadata 结合方法装饰器实现的一个自定义语法检查的例子
    使用 TypeScript 自定义装饰器给类的方法增添监听器 Listener
    爬取本blog所有文章链接
    90分钟掌握Python多线程爬虫(全程实战)
    python学习笔记
    Python零基础爬虫教学(实战案例手把手Python爬虫教学)
    开发,功能测试点,注意
    workerman
    tp6 文档
    公共方法
  • 原文地址:https://www.cnblogs.com/zouyajun/p/3728727.html
Copyright © 2020-2023  润新知