This article introduces the difference between is_file, file_exists and is_dir in php. Friends in need can refer to it.
is_file only determines whether the file exists;
The code is as follows
|
Copy code
|
||||||||||||||
$file = "test.txt"; if(is_file($file)) { echo ("$file is a regular file");
echo ("$file is not a regular file"); }?> Output: test.txt is a regular file file_exists determines whether the file or directory exists;
| |||||||||||||||
echo file_exists("test.txt"); |