欧美日韩一区二区三区四区不卡,日韩欧美视频一区二区三区四区,久久精品欧美一区二区三区不卡,国产精品久久久乱弄

咨詢電話:186 7916 6165 咨詢電話:186 7916 6165 (微信同號)    在線QQ:181796286
NEWS BLOG ·
學無止境
關注開優網絡 關注前沿
PHP Web開發之操作XML
PHP自定義分頁類

PHP自定義驗證碼

發表日期:2016-01-26    文章編輯:南昌開優網絡    瀏覽次數:4995    標簽:PHP應用

php驗證碼
<?php
session_start();
$rnd_code=4;
for($i=0;$i<$rnd_code;$i++){
$nmsg .=dechex(mt_rand(0,15));
}
$_SESSION["code"]=$nmsg;
$width=75;
$height=25;
$img=imagecreatetruecolor($width,$height);
$white=imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$white);
//邊框
$flag=false;
if($flag){
$black=imagecolorallocate($img,0,0,0);
imagerectangle($img,0,0,$width-1,$height-1,$black);
}

//隨機線條
for($i=0;$i<6;$i++){
$rnd_color = imagecolorallocate($img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imageline($img,mt_rand(0,$width),mt_rand(0,$height),mt_rand(0,$width),mt_rand(0,$height),$rnd_color);
}
//雪花
for($i=0;$i<100;$i++){
$rnd_color=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
imagestring($img,1,mt_rand(1,$width),mt_rand(1,$height),'*',$rnd_color);
}
//生成隨機驗證碼
for($i=0;$i<strlen($_SESSION['code']);$i++){
$rnd_color=imagecolorallocate($img,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));
imagestring($img,5,$i*$width/$rnd_code+mt_rand(1,10),mt_rand(1,$height/2),$_SESSION['code'][$i],$rnd_color);
}
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
?>

主站蜘蛛池模板: 左云县| 潞西市| 德惠市| 元谋县| 色达县| 汽车| 平潭县| 武城县| 富宁县| 汉沽区| 西昌市| 滨州市| 和龙市| 开江县| 新宁县| 达日县| 潜山县| 桦南县| 梅河口市| 田林县| 利川市| 巴中市| 丹凤县| 临西县| 桓台县| 扬中市| 孟村| 枣庄市| 泊头市| 托克逊县| 巴里| 龙里县| 成安县| 清水河县| 纳雍县| 泰来县| 礼泉县| 柳林县| 定西市| 龙里县| 谷城县|