file_exists — Check whether the file or directory exists
Description:
bool file_exists ( string $filename )
Returns TRUE if the file or directory specified by filename exists, otherwise returns FALSE.
Example
Example one
<?php $filename = '/www/aa/to/foo.txt'; if (file_exists($filename)) { echo "文件$filename exists"; } else { echo "文件$filename 不存在"; } ?>
The output result is:
File/www/aa/to/foo.txt already exists
Example two
<?php echo file_exists("test.txt"); ?>
Use file_exists directly to return true or false.
The above is the detailed content of Detailed explanation of the use of file_exists() function in php. For more information, please follow other related articles on the PHP Chinese website!