Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

is_writable

Checks whether a file or folder can be written to.

Syntax

is_writable(string $filename): bool

Parameters

ParameterTypeDescription
$filenamestringThe path to a file or folder.

Return value

bool`true` if writing is allowed.

Examples

Can the temporary folder be written to:

<?php
 
var_dump(is_writable(sys_get_temp_dir()));

Output:

bool(true)

Notes

On a server the upload and cache folders must be writable by the user PHP runs as.

See also

Related recipes

In the tutorial

  • Reading and writing files — Working with files in PHP — writing, reading, appending, reading line by line, checking existence and deleting.

Thanks for reading!

Donate to the site — we work hard for you.