Home > Backend Development > PHP Tutorial > PHP uses file_exists to check if a file or directory exists

PHP uses file_exists to check if a file or directory exists

WBOY
Release: 2016-07-25 09:04:50
Original
1025 people have browsed it
  1. $filename = '/jbxue.com/aa/to/foo.txt';
  2. if (file_exists($filename)) {
  3. echo "File $filename exists";
  4. } else {
  5. echo "File $filename does not exist";
  6. }
  7. ?>
Copy code

Output result: The file /jbxue.com/aa/to/foo.txt already exists

Example 2:

  1. echo file_exists("jbxue.com.txt");
  2. ?>
Copy code

Directly use file_exists to return true or false



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