header("Content-type: image/png,charset='utf-8'");
	$im = imagecreatetruecolor(400, 30);
	//白色
	$white = imagecolorallocate($im, 255, 255, 255);
	//红色
	$red = imagecolorallocate($im, 255, 0, 0);
	//黑色
	$black=imagecolorallocate($im, 0, 0, 0);
	//绿色
	$green=imagecolorallocate($im, 0, 255, 0);
	//蓝色
	$blue=imagecolorallocate($im, 0, 0, 255);
	$color_arr=array($green,$blue,$red);
	$color=array_rand($color_arr);
	$text = '我靠这验证码太变态啦';
	$textlen=iconv_strlen($text,'utf-8');//计算字符串长度
	//随机截取两个字符,变色显示
	$p1=rand(1,$textlen)-1;
	while(($p2=rand(1,$textlen)-1)==$p1);
	$w1=iconv_substr($text,$p1,1,'utf-8');
	$w2=iconv_substr($text,$p1,1,'utf-8');
	//字体文件
	$font = 'simkai.ttf';
	imagefilledrectangle($im, 0, 0, 399, 29, $white);
	for($i=0;$i<$textlen;$i++)
	{
	if($i==$p1||$i==$p2)
	{
	imagettftext($im, 15, 0, 20*($i-1)+20, 20, $color_arr[$color], $font, iconv_substr($text,$i,1,'utf-8'));
	}
	else
	{
	imagettftext($im, 15, 0, 20*($i-1)+20, 20, $black, $font, iconv_substr($text,$i,1,'utf-8'));
	}
	}
	imagepng($im);
	imagedestroy($im);
	?>
验证码中的字符并不是同一种颜色,让用户输入指定颜色的验证码,安全性更好。
 php空间
          
          php空间
          
          
php空间
价格:80元 (全网低价)
支持PHP相关程序
联系电话:021-51095771 021-51087627 夜间技术:021-51087637  紧急电话:18916133353  传真:021-51087637-202 
    版权所有:上海羽灿计算机科技有限公司 中国网格(cnwg.cn/cnwg.cc)©2003-2013 All Rights Reserved. 
    地址:上海市沪松公路1519弄18号1310室 邮编:201108 ICP经营许可证编号:沪B2-20060019 沪ICP备06012189号 
 
		
	 
我要评价