Explanation:
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 computernamesharefilename to check for network shared files.
In Windows, use //computername/share/filename or \computernamesharefilename to check shared files on the network.
Example 1
<?php $filename = '/jb51.net/aa/to/foo.txt'; if (file_exists($filename)) { echo "文件$filename exists"; } else { echo "文件$filename 不存在"; } ?>
The output result is:
The file /jb51.net/aa/to/foo.txt already exists
Example 2
<?php echo file_exists("jb51.net.txt"); ?>
Use file_exists directly to return true or false.
The above is the entire content of this article, I hope you all like it.