This example describes how PHP uses the Get_headers function to determine whether a remote file exists. Share to everyone for your reference. The implementation method is as follows:
Before the process about PHP to determine whether remote files exist in the article is the use of Fopen,sockt,curl function to check whether remote files exist, the following I introduce the use of get_headers to check whether remote files exist, interested friends can refer to.
Let's take a quick look at the get_headers () function
Get_headers () returns an array m containing the headers sent by the server in response to an HTTP request.
Get_headers: The sending server responds to HTTP requests
Get_headers (string url[link format])
Get_headers () returns the server HTTP request as an array m if execution fails, it will return false and an error level e_warning,
The optional parameter is set to 1,get_headers () to analyze the system's response speed and the keys in the set array.
The instance code for excluding redirects is as follows:
The code is as follows:
<?php /** * Fetches all the real headers sent by the server in response to a HTTP request without redirects * Get headers that do not contain redirects */
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.