Description
BOOL File_exists (String $filename)
Returns TRUE if the file or directory specified by filename is present, otherwise it returns FALSE.
In fact, PHP tutorial file_exists function and file_exists syntax we've already talked about it, so let's take a look at some of the ways and examples of how it's used.
The file or directory of the path.
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 \\computername\share\filename to check for shared files on your network.
This is a very simple example of a
Copy Code code as follows:
<?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
Take another look at example two
Copy Code code as follows:
<?php
Echo file_exists ("Jb51.net.txt");
?>
We'll just use file_exists to return ture or false.