Home >Backend Development >PHP Tutorial >Detailed explanation of the use of file_exists function in php_PHP tutorial
This article will explain to you the file_exists function in php to determine whether a file or directory exists. Attached are several classic examples. If necessary, Partners can refer to it.
Description:
bool file_exists ( string $filename )
Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.
On Windows, use //computername/share/filename or computernameshare filename to check for network shared files.
In Windows, use //computername/share/filename or \computernamesharefilename to check shared files on the network.
Example 1
?
2 3 4 5
6 7 8 |
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "File $filename exists";
} else {
|
1 |
<🎜>echo file_exists("jb51.net.txt");<🎜> <🎜>?> |