containsFile.php
Table of Contents
Functions
- containsFile() : bool
- Tells whether a directory holds a file, at any depth.
Functions
containsFile()
Tells whether a directory holds a file, at any depth.
containsFile(string $directory) : bool
Unlike hasFiles(), which only looks at the first level, this walks the whole tree: a directory holding nothing but empty sub-directories holds no file, one holding a file five levels down does.
Links count as files and are not followed: a link is something the directory holds, whatever it points at.
A directory that cannot be read is taken to hold a file, and so is one with an unreadable sub-directory. That is the safe answer for the usual question behind this call — "can this be removed as empty?" — since what cannot be seen cannot be shown to be empty.
Parameters
- $directory : string
-
The directory to look into.
Tags
Return values
bool —True when a file or a link is found anywhere under it, or when part of it cannot be read; false when it holds only directories, holds nothing, or is not there.