php determines whether a file or directory (folder) exists
The php library has its own function to determine whether a file or directory exists. file_exists determines whether a file exists, and is_dir determines a directory ( folder) exists. Specific examples are as follows:
$file='index.php';
$dir='www.phpernote.com/wwwroot/';
if(file_exists($dir.$file)){
echo '文件'.$file.'存在';
}else{
echo '文件'.$file.'不存在';
}
if(is_dir($dir)){
echo '目录'.$dir.'存在';
}else{
echo '目录'.$dir.'不存在';
}
Copy after login
Articles you may be interested in
- How to clear (delete) the files in the specified directory without deleting the directory folder with php
- php get all the files in the directory A program that saves the results to an array
- How to determine whether a remote file exists in PHP
- Detailed explanation of linux chmod (file or folder permission setting) command parameters and usage
- PHP determines whether functions, classes, and class methods exist
- Linux delete files and folders command rm command details
- The safest and most realistic solution for PHP to determine the type of uploaded files
- php method to determine whether a string is all in English, pure Chinese, or a combination of Chinese and English
http://www.bkjia.com/PHPjc/982049.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/982049.htmlTechArticlephp determines whether a file or directory (folder) exists. The php library has its own function to determine whether a file or directory exists. , file_exists determines whether the file exists, is_dir determines whether the directory (folder) is...