php file_exists function to check whether a file or directory exists_PHP tutorial

WBOY
Release: 2016-07-21 15:38:15
Original
1105 people have browsed it

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

www.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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!