Home > Backend Development > PHP Tutorial > Application example of function is_dir() to detect whether directory exists

Application example of function is_dir() to detect whether directory exists

WBOY
Release: 2016-07-25 09:00:45
Original
852 people have browsed it
  1. var_dump(is_dir('a_file.txt')) . "n";
  2. var_dump(is_dir('bogus_dir/abc')) . "n";
  3. var_dump(is_dir('.. ')); //one dir up
  4. ?>
Copy code

output: bool(false) bool(false) bool(true)

Example 2:

  1. $file = "images";
  2. if(is_dir($file))
  3. {
  4. echo ("$file is a directory");
  5. }
  6. else
  7. {
  8. echo ( "$file is not a directory");
  9. }
  10. ?>
Copy the code

output: images is a directory



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