is_writable()

is_writable() — Tells whether the filename is writable.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns true if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.

Signature

is_writable(string $filename): bool

Parameters

ParameterTypeWhat it takes
$filenamestringThe filename being checked.

Return value

Returns true if the filename exists and is writable.

Example

A runnable snippet:

$filename = 'test.txt'; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; }

See also

is_readable(), file_exists(), fwrite()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page is_writable() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.