中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php生成驗證碼代碼

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
<?php
session_start ();
header ( 'Content-type: image/png' );
//創(chuàng)建圖片
$im = imagecreate($x=130,$y=45 );
$bg = imagecolorallocate($im,rand(50,200),rand(0,155),rand(0,155)); //第一次對 imagecolorallocate() 的調用會給基于調色板的圖像填充背景色
$fontColor = imageColorAllocate ( $im, 255, 255, 255 );   //字體顏色
$fontstyle = 'rock.ttf';     //字體樣式,這個可以從c:\windows\Fonts\文件夾下找到,我把它放到和authcode.php文件同一個目錄,這里可以替換其他的字體樣式
//產生隨機字符
for($i = 0; $i < 4; $i ++) {
	$randAsciiNumArray = array (rand(48,57),rand(65,90));
	$randAsciiNum = $randAsciiNumArray [rand ( 0, 1 )];
	$randStr = chr ( $randAsciiNum );
	imagettftext($im,30,rand(0,20)-rand(0,25),5+$i*30,rand(30,35),$fontColor,$fontstyle,$randStr);
	$authcode .= $randStr;
}
$_SESSION['authcode'] = $randFourStr;//用戶和用戶輸入的驗證碼做比較

//干擾線
for ($i=0;$i<8;$i++){
	$lineColor        = imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
	imageline ($im,rand(0,$x),0,rand(0,$x),$y,$lineColor);
}

//干擾點
for ($i=0;$i<250;$i++){
	imagesetpixel($im,rand(0,$x),rand(0,$y),$fontColor);
}
imagepng($im);
imagedestroy($im);
?>

標簽:

版權申明:本站文章部分自網絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:NSData使用與分析

下一篇:Objective-C遍歷數(shù)組NSArray的3種方法