亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

丫頭
關(guān)注

關(guān)注後可及時瞭解他的動態(tài)資訊

課程筆記
  • 所屬章節(jié)課程:PHP用戶註冊登入系統(tǒng)之驗證碼製作

    <?php //生成驗證碼的背景 header('Content-type:image/jpeg'); //背景圖的尺寸 $width=60; $height=15; //創(chuàng)建畫布 $img=imagecreatetruecolor($width, $height); //分配顏色 $white=imagecolorallocate($img, 0xff, 0xff, 0xff); //填充顏色到畫布 imagefill($img, 0, 0, $white); //生成驗證碼的值 $chars='1234567890'; $chars_len=strlen($chars); $code_len=4;//驗證碼長度 $code="";//初始值 for ($i=1; $i < $code_len; ++$i) { $rand=mt_rand(0,$chars_len-1);//隨機取出四個數(shù)字 $code=$rand;//將取出的數(shù)字連接在一起 } //存入session中,用驗證 session_start(); $_SESSION['ver_code']=$code; //隨機分配字符串顏色 $str_color=imagecolorallocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); //計算字符串居中顯示 //字符串的大小 $font=5; //畫布尺寸 $img_w=imagesx($img); $img_h=imagesy($img); //字體尺寸 $font_w=imagefontwidth($font); $font_h=imagefontheight($font); //字符串尺寸 $code_w=$font_w*$code_len; $code_h=$font_h; $x=($img_w-$code_w)/2; $y=($img_h-$code_h)/2; //把驗證碼輸出到畫布上 imagestring($img, $font, $x, $y, $code, $str_color); //直接輸出 imagejpeg($img); imagedestroy($img); ?>

    2018-04-215個贊