您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

一个PHP验证码类代码分享(已封装成类)_PHP教程

2024/3/6 17:56:50发布21次查看
复制代码 代码如下:
codes = implode('',array_slice($codearray,0,4));
}
public function createimg()
{
$_session['check_pic'] = $this->codes;
$img = imagecreate(70,25);
imagecolorallocate($img,222,222,222);
$testcolor1 = imagecolorallocate($img,255,0,0);
$testcolor2 = imagecolorallocate($img,51,51,51);
$testcolor3 = imagecolorallocate($img,0,0,255);
$testcolor4 = imagecolorallocate($img,255,0,255);
for ($i = 0; $i {
imagestring($img,rand(5,6),8 + $i * 15,rand(2,8),$this->codes[$i],rand(1,4));
}
imagegif($img);
}
}
$code = new securitycode();
$code->createimg();
$code = null;
?>
封装成类之后,加入了构造函数,使用起来也方便些。你也可以继续完善下这个验证码类,比如加入析构函数,如何更节省内存等等。
http://www.bkjia.com/phpjc/323972.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/323972.htmltecharticle复制代码 代码如下: ?php session_start(); header(content-type: image/gif); class securitycode { private $codes = ''; function __construct() { $code = '0-1-2-3-4-5-6-7-8-9-...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product