課程
/后端開發(fā)
/PHP
/PHP進階篇-GD庫圖像處理
麻煩支援一下
2017-05-16
源自:PHP進階篇-GD庫圖像處理 1-1
正在回答
<?php $width?=?300; $height?=?100; $image?=imagecreatetruecolor($width,$height);?//創(chuàng)建畫布 $white?=?imagecolorallocate($image,255,255,255);//畫布背景色 imagefilledrectangle($image,0,0,$width,$height,$white);?//填充畫布背景色 for($i=0;$i<4;$i++){ ????$fontsize?=?mt_rand(30,40); ????$fontcolor=imagecolorallocate($image,rand(0,?120),rand(0,?120),rand(0,?120)); ????//驗證碼顏色,放在循環(huán)里,每個字符顏色不同 ????$data?=?"abcdefghijklmnpqrstuvwyz123456789"; ????$fontcontent?=?substr($data,rand(0,?strlen($data)-1),?1); ????$x=($i*300/4)+rand(30,?50); ????$y=rand(40,?70); ????$angle?=?mt_rand(-15,15); ????imagettftext($image,$fontsize,$angle,$x,$y,$fontcolor,'msyh.ttc',$fontcontent); } header("content-type:image/jpeg;charset=utf-8"); ob_clean();?//這個就很怪,有時候不加就報錯 imagejpeg($image); imagedestroy($image); ?>
歡迎采納
舉報
想通過PHP中GD函數(shù)庫靈活操作圖像嗎,點擊學(xué)習(xí)本教程可以實現(xiàn)
1 回答求 酷炫驗證碼!
1 回答完整代碼,僅供參考
2 回答急,驗證碼顯示不出來?求解答
1 回答驗證碼的封裝,$tex=tstr_shuffle($string)[0];這行代碼沒看懂
2 回答漢字驗證碼出現(xiàn)四個框框
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-05-16
歡迎采納