首页 > Web开发 > 详细

使用php设计简单验证码

时间:2017-01-04 17:32:03      阅读:228      评论:0      收藏:0      [点我收藏+]

2017,1,3,星期二

  一、所需的代码,步骤:

    1.新建画布[新建图像]

    resource imagecreatetruecolor ( int $width , int $height );

    2.选取颜色

    int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha );

    3.画图

    bool imageellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color )

    4.区域填充

    bool imagefill( resource $image   , int $x   , int $y   , int $color );

    5.生成随机数

    int mt_rand( int $min, int $max );

    6.随机打乱一个字符串

    string str_shuffle( string $str );

    7.用 TrueType 字体向图像写入文本

    array imagettftext ( resource $image , float $size , float $angle  , int $x  , int $y , int $color , string $fontfile  , string $text  );

    8.返回字符串的子串

    string substr ( string $string, int $start[, int $length  ] )

    9.发送原生 HTTP 头

    void header ( string $string [, bool $replace = true [, int $http_response_code ]] );

    10.以 PNG 格式将图像输出到浏览器或文件

    bool imagepng ( resource $image [, string $filename ] );

    11.销毁一图像

    bool imagedestroy  ( resource $image );

使用php设计简单验证码

原文:http://12254251.blog.51cto.com/12244251/1888727

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!