Home  >  Article  >  Backend Development  >  PHP determines whether a file exists?

PHP determines whether a file exists?

(*-*)浩
(*-*)浩Original
2019-09-21 10:00:1612622browse

PHP file_exists() function

PHP determines whether a file exists?

Definition and usage

file_exists() function checks files Or the directory exists. (Recommended learning: PHP programming from entry to proficiency)

Returns true if the specified file or directory exists, otherwise returns false.

Syntax

file_exists(path)

path, required. Specifies the path to be checked.

Example

$file = "check.txt";

if(file_exists($file))
{
    echo "当前目录中,文件".$file."存在";
}
else
{
     echo "当前目录中,文件".$file."不存在";
}

The above is the detailed content of PHP determines whether a file exists?. 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