PHP file_exists is a function that checks for the existence of a file or directory
- 2020-03-31 20:39:18
- OfStack
instructions
Bool file_exists (string $filename)
Returns TRUE if the file or directory specified by filename exists, or FALSE otherwise.
We've already covered the file_exists function and file_exists syntax in the PHP tutorial, so let's take a look at how and how to use it
Path to a file or directory.
On Windows, use / / computer name/share/file name or computer name share file name to check for network Shared files.
In Windows with a / / computername/share/filename or \ \ computername \ share \ filename to check in the network file sharing.
This is a very simple example one
The output result is:
The file /jb51.net/aa/to/foo.txt already exists
Let's look at example two
So we just use file_exists to return true or false
Bool file_exists (string $filename)
Returns TRUE if the file or directory specified by filename exists, or FALSE otherwise.
We've already covered the file_exists function and file_exists syntax in the PHP tutorial, so let's take a look at how and how to use it
Path to a file or directory.
On Windows, use / / computer name/share/file name or computer name share file name to check for network Shared files.
In Windows with a / / computername/share/filename or \ \ computername \ share \ filename to check in the network file sharing.
This is a very simple example one
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo " file $filename exists";
} else {
echo " file $filename There is no ";
}
?>
The output result is:
The file /jb51.net/aa/to/foo.txt already exists
Let's look at example two
<?php
echo file_exists("jb51.net.txt");
?>
So we just use file_exists to return true or false