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

PHP determines whether a file exists?

(*-*)浩
Release: 2023-02-24 15:14:01
Original
12679 people have browsed it

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)
Copy after login

path, required. Specifies the path to be checked.

Example

$file = "check.txt";

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

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template