I need to check if a file is on HDD at a specified location ($path.$file_name).
Which is the difference between is_file()
and file_exists()
functions and which is better/faster to use in PHP?
is_file()
will return false
if the given path points to a directory. file_exists()
will return true
if the given path points to a valid file or directory. So it would depend entirely on your needs. If you want to know specifically if it's a file or not, use is_file()
. Otherwise, use file_exists()
.