Home >Backend Development >PHP Tutorial >Detailed explanation of the use of file_exists function in php_PHP tutorial

Detailed explanation of the use of file_exists function in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:54:351225browse

Detailed explanation of the use of file_exists function in php

This article will explain to you the file_exists function in php to determine whether a file or directory exists. Attached are several classic examples. If necessary, Partners can refer to it.

Description:

bool file_exists ( string $filename )

Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.

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.

Example 1

 ?

1

2

3

4

5

6

7

8

$filename = '/jb51.net/aa/to/foo.txt';

if (file_exists($filename)) {

echo "文件$filename exists";

} else {

echo "文件$filename 不存在";

}

?>

1

2

3

4

5

1

2

3

echo file_exists("jb51.net.txt");

?>

6

7

8

$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: The file /jb51.net/aa/to/foo.txt already exists Example 2  ?
1
2 3
<🎜>echo file_exists("jb51.net.txt");<🎜> <🎜>?>
Use file_exists directly to return true or false. The above is the entire content of this article, I hope you all like it.  Note< >: For more exciting tutorials, please pay attention to Bangke Home Programming http://www.bkjia.com/PHPjc/996755.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/996755.htmlTechArticleDetailed explanation of the use of file_exists function in php. This article explains to you the file_exists function in php to determine whether a file or directory exists. Attached are a few classic examples, friends in need can...
Statement:
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