Description
bool file_exists ( string $filename )
Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.
In fact, we have already talked about the file_exists function and file_exists syntax in the PHP tutorial. Let’s take a look at its usage and examples.
The file or directory of the path.
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.
This is a very simple example -
Copy code The code is 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 result is:
File/jb51.net/ aa/to/foo.txt already exists
Let’s take a look at Example 2
Copy the code The code is as follows:
echo file_exists("jb51.net.txt");
?>
For this we will directly use file_exists to return true or false
http://www.bkjia.com/PHPjc/321791.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321791.htmlTechArticleDescription bool file_exists ( string $filename ) Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE . In fact, in the php tutorial file_exists function and file_ex...