Home >Backend Development >PHP Tutorial >PHP gets the remote verification code to the local PHP function code_PHP tutorial

PHP gets the remote verification code to the local PHP function code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:30:34870browse

PHP obtains the verification code image locally and supports verification codes in three formats: png, gif, and jpg. During implementation, PHP uses PHP's built-in exif_imagetype function to determine the image format, which is indeed more convenient. Those who learn PHP may wish to refer to this code:

view sourceprint?01

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

 03set_time_limit(0);//Set the timeout

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

 05$url = "http://vcer.baidu.com/verify";

 06if(empty($url)){

 07 echo "No picture";

 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?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/765433.htmlTechArticlePHP obtains the verification code image locally and supports verification codes in three formats: png, gif, and jpg. During implementation, PHP uses PHP's built-in exif_imagetype function to determine the image format, which is indeed more convenient...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn