Home >Backend Development >PHP Tutorial >The difference between is_file and file_exist in php
In PHP, there is a small difference between is_file and file_isexist
1) is_file:
$path ="/path/to/file/text.txt";
if(file_exists($path))
echo "File Exists ";
else
echo "File not Exists";
For example, in this example, true will be returned if the file exists, false will be returned if it does not exist, but note that if a
correct path (such as a file directory) is passed in, It will also return true:
$path ="/path/to/file";
2) file_isexist()
This will not happen. It really determines whether a file exists. If the above one is passed in, although it looks like
The correct path also returns false