Home  >  Article  >  Backend Development  >  Detailed explanation of the use of php file_exists() function

Detailed explanation of the use of php file_exists() function

怪我咯
怪我咯Original
2017-07-11 10:40:352170browse

file_exists — Check whether the file or directory exists

Syntax

bool file_exists ( string $filename )

Check whether the file or directory exists.

Parameters filename The path of the file or directory.

Return value

Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.

Note:If the file cannot be accessed due to safety mode restrictions, this function will return FALSE. However, it is possible to include using include if the file is in the directory specified by safe_mode_include_dir.

Note: Note: Because PHP's integer type is a signed integer type and many platforms use 32-bit integer types, for files above 2GB, some File System Functions may return unexpected results.

Example

1: Create a file.txt file in the F disk directory, and we determine that the file.txt file exists.

 class test{
     public function A($path){
        if(!file_exists($path)){           echo "目录文件存在!";
        }else{           echo "目录文件不存在!"; 
        }
     } 
 }$T=new test();$T->A("F:file.txt");

Output result:

Directory file exists!

The above is the detailed content of Detailed explanation of the use of php file_exists() function. 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