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

php驗(yàn)證碼實(shí)現(xiàn)代碼

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

PHP驗(yàn)證碼實(shí)現(xiàn)原理

生成隨機(jī)數(shù)或者字母保存到session中(驗(yàn)證驗(yàn)證碼的時(shí)候用),然后對(duì)生成的數(shù)字或者字母進(jìn)行繪圖!然后呈現(xiàn)在我們眼前

刷新驗(yàn)證碼:用js改變驗(yàn)證碼圖片所帶的參數(shù),讓瀏覽器不讀緩存的圖片,從而實(shí)現(xiàn)刷新驗(yàn)證碼效果!

代碼示例
$str="QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
 
$image=imagecreate(50,25);
imagecolorallocate($image,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125));
$color = imagecolorallocate($image,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
for($i=1;$i<=4;$i++) {
$date=$str[mt_rand(0,strlen($str)-1)];
$code.=$date;
}
session_start();
$_SESSION['code'] = $code;
imagestring($image,4,8,4,$code,$color);
for($i=1;$i<=30;$i++) {
imagesetpixel($image,mt_rand(0,50),mt_rand(0,25),mt_rand(125,200));
}
for($i=1;$i<=mt_rand(1,5);$i++) { imageline($image,mt_rand(0,50),mt_rand(0,25),mt_rand(0,50),mt_rand(0,25),mt_rand(100,150)); } header("content-type:image/png"); imagepng($image); ?>
數(shù)字+字母驗(yàn)證碼(各字母顏色不同):
 
<!--?php <br ?--> $str="QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
$image=imagecreate(50,25);
imagecolorallocate($image,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125));
$color[0] = imagecolorallocate($image,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
$color[1] = imagecolorallocate($image,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
$color[2] = imagecolorallocate($image,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
$color[3] = imagecolorallocate($image,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
for($i=0;$i<4;$i++) {
$date=$str[mt_rand(0,strlen($str)-1)];
$code.=$date;
imagestring($image,5,6+$i*10,4,$code[$i],$color[$i]);
}
session_start();
$_SESSION['code'] = $code;
for($i=1;$i<=30;$i++) {
imagesetpixel($image,mt_rand(0,50),mt_rand(0,25),mt_rand(125,200));
}
for($i=1;$i<=mt_rand(1,5);$i++) {
imageline($image,mt_rand(0,50),mt_rand(0,25),mt_rand(0,50),mt_rand(0,25),mt_rand(100,150));
}
header("content-type:image/png");
imagepng($image);

來自:php驗(yàn)證碼實(shí)現(xiàn)原理

標(biāo)簽: 代碼

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

上一篇:在Shell中使用日期運(yùn)算和比較

下一篇:C#通過設(shè)置注冊表實(shí)現(xiàn)文件關(guān)聯(lián)