$im = imagecreatetruecolor ( " /> 岛国av一区二区三区,欧美日本高清一区,日本在线啊啊

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php 生成隨機驗證碼圖片代碼

復制代碼 代碼如下:
<?php
/** 默認首頁 **/
class DefaultController extends AppController
{
public function index() {
$len = 5;
$str = "ABCDEFGHIJKLNMPQRSTUVWXYZ123456789";

$im = imagecreatetruecolor ( 70, 20 );
$bgc = imagecolorallocate($im, 255, 255, 255);
$bgtxt = imagecolorallocate($im, 220, 220, 220);

//隨機調色板
$colors = array(
imagecolorallocate($im, 255, 0, 0),
imagecolorallocate($im, 0, 200, 0),
imagecolorallocate($im, 0, 0, 255),
imagecolorallocate($im, 0, 0, 0),
imagecolorallocate($im, 255, 128, 0),
imagecolorallocate($im, 255, 208, 0),
imagecolorallocate($im, 98, 186, 245),
);

//填充背景色
imagefill($im, 0, 0, $bgc);

//隨機獲取數字
$verify = "";
while (strlen($verify) < $len) {
$i = strlen($verify);
$random = $str[rand(0, strlen($str))];
$verify .= $random;

//繪制背景文字
imagestring($im, 6, ($i*10)+3, rand(0,6), $random, $bgtxt);
//繪制主文字信息
imagestring($im, 6, ($i*10)+3, rand(0,6), $random, $colors[rand(0, count($colors)-1)]);
}

//添加隨機雜色
for($i=0; $i<100; $i++) {
$color = imagecolorallocate($im, rand(50,220), rand(50,220), rand(50,220));
imagesetpixel($im, rand(0,70), rand(0,20), $color);
}

//將驗證碼存入$_SESSION中
sess("verify", $verify);

//輸出圖片并釋放緩存
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
};
?>

php技術php 生成隨機驗證碼圖片代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 饶阳县| 通道| 临沭县| 东方市| 永春县| 苗栗市| 含山县| 开化县| 宁武县| 吕梁市| 樟树市| 双辽市| 五原县| 泸水县| 呼玛县| 元谋县| 孟津县| 中方县| 海兴县| 九龙坡区| 赤水市| 华池县| 耒阳市| 利辛县| 佳木斯市| 土默特右旗| 新巴尔虎右旗| 高陵县| 遵化市| 巧家县| 防城港市| 玉溪市| 台山市| 左云县| 泽普县| 平舆县| 星座| 平顶山市| 澄城县| 车致| 和顺县|