$im = imagecreatetruecolor ( " /> 国产精品日韩欧美一区,xxxx成人,精品久久久999

色尼玛亚洲综合影院,亚洲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 生成隨機驗證碼圖片代碼,轉載需保留來源!

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

主站蜘蛛池模板: 同德县| 北京市| 沐川县| 大石桥市| 资兴市| 白水县| 浪卡子县| 女性| 石阡县| 光山县| 丹巴县| 中阳县| 沾益县| 盐亭县| 彰武县| 乌兰察布市| 牙克石市| 屏东县| 六安市| 凤阳县| 灵璧县| 收藏| 靖宇县| 囊谦县| 都昌县| 南康市| 长海县| 凉山| 红桥区| 乌恰县| 鸡东县| 岗巴县| 潮州市| 临江市| 蒲江县| 大兴区| 麻栗坡县| 共和县| 乐山市| 中江县| 通江县|