This article is to explain the PHP in the judge file or whether the directory exists file_exists function, with a few classic examples, the need for small partners can refer to.
Description
BOOL File_exists (String $filename)
Returns TRUE if the file or directory specified by filename is present, otherwise it returns FALSE.
On Windows, use the//Computer name/share/file name or computer name to share the file name to check for network shared files.
In Windows, use//computername/share/filename or computernamesharefilename to check for shared files on your network.
Instance One
?
| 1 2 3 4 5 6 7 8 |
<?php $filename = '/jb51.net/aa/to/foo.txt '; if (file_exists ($filename)) {echo "file $filename exists";} else {echo "file $filename does not exist";}?> |
The output results are:
File/jb51.net/aa/to/foo.txt already exists
Example Two
?
| 1 2 3 |
<?php echo file_exists ("Jb51.net.txt");?> |
Returns ture or false directly with file_exists.
The above mentioned is the entire content of this article, I hope you can enjoy.
Note < > : More Wonderful tutorials please focus on Triple programming