>  기사  >  백엔드 개발  >  PHP验证码效能的实现

PHP验证码效能的实现

WBOY
WBOY원래의
2016-06-13 10:39:14702검색

PHP验证码功能的实现

/**	 *产生验证码图片	 */	public function actionVerfiycode() {		Header ( "Content-type: image/gif" );		$border = 0; //是否要边框 1要:0不要		$how = 4; //验证码位数		$w = $how * 15; //图片宽度		$h = 20; //图片高度		$fontsize = 5; //字体大小		$alpha = "abcdefghijkmnopqrstuvwxyz"; //验证码内容1:字母		$number = "0123456789"; //验证码内容2:数字		$randcode = ""; //验证码字符串初始化		srand ( ( double ) microtime () * 1000000 ); //初始化随机数种子		$im = ImageCreate ( $w, $h ); //创建验证图片		$bgcolor = ImageColorAllocate ( $im, 255, 255, 255 ); //设置背景颜色		ImageFill ( $im, 0, 0, $bgcolor ); //填充背景色		if ($border) {			$black = ImageColorAllocate ( $im, 0, 0, 0 ); //设置边框颜色			ImageRectangle ( $im, 0, 0, $w - 1, $h - 1, $black ); //绘制边框		}		for($i = 0; $i open();			Yii::app()->session->add('randcode',$randcode);		/*绘图结束*/		Imagegif ( $im );		ImageDestroy ( $im );		/*绘图结束*/		}	


引自:http://www.admin5.com/article/20080314/75984.shtml
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.