Home > Backend Development > PHP Problem > php determines whether a folder exists

php determines whether a folder exists

王林
Release: 2023-02-25 18:16:02
Original
6583 people have browsed it

php determines whether a folder exists

PHP determines whether a file or directory exists

1. file_exists() function

Judgement Whether the file exists

Example:

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

2. is_dir() function

Determine whether the directory exists

Example:

//$dir = "c:/datacheck";
if(is_dir($dir))
{
    echo "当前目录下,目录".$dir."存在";
}
else
{
     echo "当前目录下,目录".$dir."不存在";
}
Copy after login

Recommended tutorial: PHP video tutorial

The above is the detailed content of php determines whether a folder exists. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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