PHP is_writable() Function

Definition and Usage

The is_writable() function determines whether the specified file is writable.

Syntax

is_writable(file)
Parameter Description
file Required. Specifies the file to be checked.

Description

Returns true if the file exists and is writable.file The parameter can be a directory name that allows for writeable check.

Tips and Comments

Comment:The result of this function will be cached. Please use clearstatcache() to clear the cache.

Example

<?php
$file = "test.txt";
if(is_writable($file))
  {
  echo("$file is writeable");
  }
else
  {
  echo("$file is not writeable");
  }
?>

Output:

test.txt is writeable