Home  >  Article  >  Backend Development  >  php determines whether directory exists

php determines whether directory exists

王林
王林Original
2019-09-25 17:55:554822browse

php determines whether directory exists

PHP determines whether a file or directory exists

file_exists: determines whether a file exists

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

is_dir: Determine whether the directory exists

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

Note: The result of this function will be cached. Please use clearstatcache() to clear the cache.

Recommended tutorial: PHP video tutorial

The above is the detailed content of php determines whether directory 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