clearFile.php
Table of Contents
Functions
- clearFile() : bool
- Clears the content of a file while keeping the file itself.
Functions
clearFile()
Clears the content of a file while keeping the file itself.
clearFile(string|null $file[, bool $assertable = true ]) : bool
This function empties the given file. Returns true if the file was successfully cleared, false otherwise.
The behavior on failure depends on the $assertable parameter:
- If
$assertableis true (default), a FileException is thrown if the file does not exist or is not writable. - If
$assertableis false, no exception is thrown; the function simply returns false on failure.
Parameters
- $file : string|null
-
The full path to the file to clear.
- $assertable : bool = true
-
Whether to throw exceptions on failure (default: true).
Tags
Return values
bool —True if the file was cleared successfully, false otherwise.