English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The file_exists() function can check if a file or directory exists. If the file or directory exists, this function returns true, otherwise it returns false.
bool file_exists ( string $filename )
This function can check if a file or directory exists.
<?php $filename = "/PhpProject/sample.txt" if(file_exists($filename)) { echo "File $filename exists"; } else { echo "File $filename does not exist"; } ?>
Output Result
File /PhpProject/sample.txt exists