PHP function code for obtaining the remote verification code to the local machine _ PHP Tutorial

Source: Internet
Author: User
PHP obtains the remote verification code to the local PHP function code. PHP obtains the verification code image locally and supports the verification code in png, gif, and jpg formats. During implementation, PHP determines that the image format is the exif_imagetype function built in php. it is true that the comparison party PHP obtains the verification code image locally and supports verification codes in png, gif, and jpg formats. During implementation, PHP judges that the image format is the exif_imagetype function built in php, which is really convenient. for PHP learning, refer to the following code:

View sourceprint? 01

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

03set_time_limit (0); // Set the timeout value.

04 $ url = $ _ GET ['URL'];

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

06if (empty ($ url )){

07 echo "no image ";

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}

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

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

24 imagedestroy ($ image );

25 ImagePng ($ bg );

26?>

Bytes. During implementation, PHP judges that the image format is the exif_imagetype function built in php. it is indeed a comparison...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.