PHP determines if a good way image is valid

Source: Internet
Author: User
Tags ranges
PHP determines if remote pictures are valid

?

$url = "http://www.iteye.com/upload/logo/user/275746/46a4c886-427e-3554-b195-083430beb92a.jpg"; echo "$url
"; $arr = Get_headers ($url, 1); Echo $arr [" Content-type "]; Image/jpeg

The following are the manuals:

get_headers () returns an array that contains the headers sent by the server in response to an HTTP request. If it fails, it returns false and emits an e_warning level error message.

If the optional format parameter is set to 1, get_headers () parses the corresponding information and sets the array's key name.

??

$url = ' http://www.example.com ';p rint_r (get_headers ($url));p Rint_r (Get_headers ($url, 1));?  > The output of the example above is similar to the following: Array (    [0] = http/1.1 + OK    [1] = Date:sat, May 2004 12:28:13 GMT    [2] = = Server: apache/1.3.27 (Unix)  (red-hat/linux)    [3] = last-modified:wed, Jan 2003 23:11:55 GMT    [4] = = ETag: " 3f80f-1b6-3e1cb03b "    [5] = Accept-ranges:bytes    [6] = content-length:438    [7] = = Connection: Close    [8] = content-type:text/html) Array (    [0] = http/1.1-OK    [Date] = Sat, 2004 12:28 : + GMT    [Server] = apache/1.3.27 (Unix)  (red-hat/linux)    [last-modified] = Wed, Jan 2003 23:11:55 GMT    [ETag] = "3f80f-1b6-3e1cb03b"    [accept-ranges] = bytes    [content-length] = 438< C18/>[connection] = Close    [Content-type] = text/html)
  • 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.