第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

這段代碼在wamp中實(shí)現(xiàn)不了圖形驗(yàn)證碼?為什么?

這段代碼在wamp中實(shí)現(xiàn)不了圖形驗(yàn)證碼?為什么?

PHP
qq_desperado_0 2016-07-01 16:49:26
<?php function?a($n,$w,$h){ $img?=?imagecreatetruecolor($w,?$h); $black?=?imagecolorallocate($img,?0x00,?0x00,?0x00); $green?=?imagecolorallocate($img,?0x00,?0xFF,?0x00); $white?=?imagecolorallocate($img,?0xFF,?0xFF,?0xFF); imagefill($img,0,0,$white);//生成隨機(jī)的驗(yàn)證碼 $code?=?''; $x?=?10?; $y?=?13?; for($i?=?0;?$i?<n;?$i++)?{ ????$tmp?=?rand(0,?9); ????$randcolor?=?imagecolorallocate($img,?rand(0,180),?rand(0,180),?rand(0,180));//隨機(jī)色 ????imagestring($img,?5,?$x,?$y,?$tmp,?$randcolor); ????$code?.=?$tmp; ????$x?+=?rand(12,25); ????$y?=?13?+?rand(-15,?15); ?//加入干擾線???? ????$lx1?=?rand(0,?100); ????$ly1?=?rand(0,?40); ????$lx2?=?rand(0,?100); ????$ly2?=?rand(0,?40); ????$randcolor?=?imagecolorallocate($img,?rand(0,255),?rand(0,255),?rand(0,255)); ????imageline($img,$lx1,$ly1,$lx2,$ly2,$randcolor); } ? //加入噪點(diǎn)干擾 for($i=0;$i<50;$i++)?{ ??imagesetpixel($img,?rand(0,?$w)?,?rand(0,?$h)?,?$black);? ??imagesetpixel($img,?rand(0,?$w)?,?rand(0,?$h)?,?$green); } //輸出驗(yàn)證碼 header("content-type:?image/png"); imagepng($img); imagedestroy($img); } a(5,100,40);
查看完整描述

1 回答

?
ChinaCJM

TA貢獻(xiàn)44條經(jīng)驗(yàn) 獲得超84個(gè)贊

在要顯示的頁面用img標(biāo)簽格式鏈接顯示

比如說,你上面代碼放在image.php頁面中,要在index.php頁面將驗(yàn)證碼顯示出來的話,就如下

<img src="image.php" />

查看完整回答
1 反對 回復(fù) 2016-07-01
  • qq_desperado_0
    qq_desperado_0
    <?php function a($n,$w,$h){ $img = imagecreatetruecolor($w, $h); $black = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)); $green = imagecolorallocate($img, 0x00, 0xFF, 0x00); $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); imagefill($img,0,0,$white); //生成隨機(jī)的驗(yàn)證碼 $code = ''; for($i = 0; $i <$n; $i++) { $code .= rand(0, 9).""; $lx1 = rand(0, 100); $ly1 = rand(0, 40); $lx2 = rand(0, 100); $ly2 = rand(0, 40); $randcolor = imagecolorallocate($img, rand(0,255), rand(0,255), rand(0,255)); imageline($img,$lx1,$ly1,$lx2,$ly2,$randcolor); } imagestring($img, 5, 10, 10, $code, $black); //加入噪點(diǎn)干擾 for($i=0;$i<50;$i++) { imagesetpixel($img, rand(0, $w) , rand(0, $w) , $black); imagesetpixel($img, rand(0, $w) , rand(0, $w) , $green); } //輸出驗(yàn)證碼 header("content-type: image/png"); imagepng($img); imagedestroy($img); } a(5,100,40); 不是吧 上面這段代碼就可以直接使用瀏覽器生成圖形驗(yàn)證碼了
  • ChinaCJM
    ChinaCJM
    <?php session_start(); function random($len) { $srcstr = "1a2s3d4f5g6hj8k9qwertyupzxcvbnm"; mt_srand(); $strs = ""; for ($i = 0; $i < $len; $i++) { $strs .= $srcstr[mt_rand(0, 30)]; } return $strs; } //隨機(jī)生成的字符串 $str = random(4); //驗(yàn)證碼圖片的寬度 $width = 50; //驗(yàn)證碼圖片的高度 $height = 25; //聲明需要?jiǎng)?chuàng)建的圖層的圖片格式 @ header("Content-Type:image/png"); //創(chuàng)建一個(gè)圖層 $im = imagecreate($width, $height); //背景色 $back = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); //模糊點(diǎn)顏色 $pix = imagecolorallocate($im, 187, 230, 247); //字體色 $font = imagecolorallocate($im, 41, 163, 238); //繪模糊作用的點(diǎn) mt_srand(); for ($i = 0; $i < 1000; $i++) { imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $pix); } //輸出字符 imagestring($im, 5, 7, 5, $str, $font); //輸出矩形 imagerectangle($im, 0, 0, $width -1, $height -1, $font); //輸出圖片 imagepng($im); imagedestroy($im); $str = md5($str); //選擇 cookie //SetCookie("verification", $str, time() + 7200, "/"); //選擇 Session $_SESSION["verification"] = $str; ?>
  • 1 回答
  • 0 關(guān)注
  • 1283 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號