Detailed explanation of the use of php file_exists() function

怪我咯
Release: 2023-03-13 13:52:01
Original
2343 people have browsed it

file_exists — Check whether the file or directory exists

Syntax

bool file_exists ( string $filename )
Copy after login

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

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!

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