PHP獲取遠(yuǎn)程驗證碼到本地的PHP函數(shù)代碼
來源:易賢網(wǎng) 閱讀:1553 次 日期:2014-09-18 14:57:21
溫馨提示:易賢網(wǎng)小編為您整理了“PHP獲取遠(yuǎn)程驗證碼到本地的PHP函數(shù)代碼”,方便廣大網(wǎng)友查閱!

PHP獲取驗證碼圖片到本地,支持png、gif、jpg三種格式的驗證碼。在實現(xiàn)時,PHP判斷圖片格式是使用的php內(nèi)置的exif_imagetype函數(shù),確實比較方便,學(xué)習(xí)PHP的不妨可參考下本代碼:

view sourceprint?01

02header("Content-type:image/png");

03set_time_limit(0);//設(shè)置超時時間

04$url = $_GET['url'];

05$url = "";

06if(empty($url)){

07 echo "沒有圖片";

08 die;

09}

10$imginfo = GetImageSize ( $url );

11$type = exif_imagetype($url);

12$imgw = $imginfo [0];

13$imgh = $imginfo [1];

14$bg = imagecreatetruecolor($imgw,$imgh);

15if($type==IMAGETYPE_GIF){

16 $image = imagecreatefromgif($url);

17}elseif($type==IMAGETYPE_JPEG){

18 $image = imagecreatefromjpeg($url);

19}elseif($type==IMAGETYPE_PNG){

20 $image = imagecreatefrompng($url);

21}

22imagecolorallocate($image,255,255,255);

23imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh);

24imagedestroy($image);

25ImagePng($bg);

26?>

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機網(wǎng)站地址:PHP獲取遠(yuǎn)程驗證碼到本地的PHP函數(shù)代碼
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)