Home  >  Article  >  Backend Development  >  Example sharing of PHP determining the existence of remote files

Example sharing of PHP determining the existence of remote files

*文
*文Original
2017-12-25 16:14:421427browse

How does PHP determine whether a remote file exists? This article mainly introduces the method of PHP to determine whether network files exist. It analyzes the skills of PHP to read network files with examples. I hope it will be helpful to everyone.

The example in this article describes how PHP determines whether a network file exists. Share it with everyone for your reference. The specific implementation method is as follows:


$file = "//m.sbmmt.com/demo/file_exists.zip";
$fileExists = @file_get_contents($file,null,null,-1,1) ? true : false;
if($fileExists){
   echo "File Exists!";
}else{
   echo "Sorry, we couldn't find the file.";
}

Related recommendations:

Detailed explanation of php file reading series methods

php File splitting and merging (resumable upload)

php File upload A brief introduction to the principle

The above is the detailed content of Example sharing of PHP determining the existence of remote files. 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