$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 生成隨機驗證碼圖片代碼,轉載需保留來源!

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

主站蜘蛛池模板: 峨眉山市| 米林县| 南宫市| 闻喜县| 谷城县| 元朗区| 文水县| 彭水| 茂名市| 平邑县| 延安市| 诸暨市| 麻栗坡县| 通州市| 东宁县| 百色市| 娱乐| 庄河市| 北海市| 丽江市| 广河县| 元氏县| 乌审旗| 布尔津县| 高安市| 万全县| 昌黎县| 宜章县| 壶关县| 怀宁县| 通渭县| 海安县| 蕲春县| 巴彦淖尔市| 深州市| 怀仁县| 芜湖市| 辛集市| 宁都县| 巴林右旗| 交城县|