Instructions: get_headers accesses a remote address and returns the HTTP headers sent by the server in the form of an array. And $header[0] is the status code returned by the server (if nothing else happens, the status code should be the first one returned). To confirm that a file exists on the remote server, just make sure that the status code returned by accessing the file is "HTTP/1.1 200 OK" (Can the status code HTTP/1.1 404 Not Found detect that a file does not exist? Leave it to the readers to think). For an example of obtaining a three-digit HTTP response code, please refer to the article PHP code to detect whether a remote file exists. |