deleteTemporaryDirectory.php
Table of Contents
Functions
- deleteTemporaryDirectory() : bool
- Deletes a directory located in the system temporary folder (recursively).
Functions
deleteTemporaryDirectory()
Deletes a directory located in the system temporary folder (recursively).
deleteTemporaryDirectory(string|array<string|int, string>|null $path[, bool $assertable = true ][, bool $isReadable = true ][, bool $isWritable = true ]) : bool
The given $path is appended to sys_get_temp_dir()
in the same way as getTemporaryDirectory():
null→ sys temp dir itself,'logs'→ "/tmp/logs",['my', 'app']→ "/tmp/my/app".
Nothing outside the temporary directory is deleted. getTemporaryDirectory() hands back
an absolute path as it stands, and joins a relative one without resolving it, so a path may well
come out of it pointing anywhere on the disk — '/etc', or a '../../..' climb. Such a path is
refused, with false, as is the temporary directory itself. The check is made on what the
filesystem resolves rather than on the string: the parent is resolved, so a linked ancestor
cannot be used to reach out, while the last segment is left as it stands, so a symbolic link
sitting in the temporary directory is removed on its own — never followed, its target kept.
Parameters
- $path : string|array<string|int, string>|null
-
Optional sub‑path(s) inside sys_get_temp_dir().
- $assertable : bool = true
-
Whether to validate the composed directory before deletion. Defaults to true.
- $isReadable : bool = true
-
Check readability (passed to assertDirectory()). Defaults to true.
- $isWritable : bool = true
-
Check writability (passed to assertDirectory()). Defaults to true.
Tags
Return values
bool —True if the directory was deleted or did not exist. False when the path is empty, is the temporary directory itself, or lies outside it.