PHP uses file_exists to check if a file or directory exists
WBOYOriginal
2016-07-25 09:04:501033browse
$filename = '/jbxue.com/aa/to/foo.txt';
if (file_exists($filename)) {
echo "File $filename exists";
} else {
echo "File $filename does not exist";
}
?>
Copy code
Output result:
The file /jbxue.com/aa/to/foo.txt already exists
Example 2:
echo file_exists("jbxue.com.txt");
?>
Copy code
Directly use file_exists to return true or false
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