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

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

PHP自定義驗證碼

發表日期:2016-01-26    文章編輯:南昌開優網絡    瀏覽次數:4979    標簽: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);
?>

主站蜘蛛池模板: 和龙市| 上思县| 观塘区| 铁岭县| 兰州市| 南宫市| 枣庄市| 炎陵县| 泾源县| 晋宁县| 雅安市| 来安县| 荥经县| 稻城县| 农安县| 韩城市| 天全县| 晋州市| 丰城市| 和田市| 永善县| 清丰县| 原阳县| 玛多县| 麻城市| 建德市| 裕民县| 舒城县| 富顺县| 杭锦后旗| 通海县| 长兴县| 仁寿县| 永定县| 文成县| 陈巴尔虎旗| 神池县| 靖边县| 阿克| 开封市| 巴楚县|