Home  >  Article  >  Backend Development  >  PHP验证码效能的实现

PHP验证码效能的实现

WBOY
WBOYOriginal
2016-06-13 10:39:14702browse

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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn