Home  >  Article  >  Backend Development  >  Example analysis of how PHP determines whether local and remote files exist

Example analysis of how PHP determines whether local and remote files exist

黄舟
黄舟Original
2017-09-07 09:37:471361browse

This article introduces the method of using PHP to determine whether a file exists, supports local and remote file determination, and provides complete calling code and demonstration.

1. Determine whether the local file exists

To determine whether the local file exists, you can use the file_exists method to determine.

2. Determine whether the remote file exists

To determine whether the remote file exists, you cannot use the file_exists method, but get the header of the remote file to determine whether it exists, such as The returned HTTP_CODE is 200 or 304.

3. Complete code

The above is the detailed content of Example analysis of how PHP determines whether local and remote files exist. For more information, please follow other related articles on the PHP Chinese website!

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