Computer >> Computer tutorials >  >> Programming >> PHP

is_writeable() function in PHP


The is_writeable() function checks whether a file is writeable. It returns TRUE if the file exists and is writeable.

The is_writeablle() function is an alias of is_writable(). A benefit of using is_writeable() instead of is_writable() is that the is_writable() function will pollute search results when searching source code for files containing the word "table".

Syntax

is_writeable(file_path)

Parameters

  • file_path − The path of the file to be checked.

Return

The is_writeable() function returns TRUE if the file exists and is writeable.

Example

<?php
$file = "demo.txt";
if(is_writeable($file)) {
   echo ("File is writeable!");
} else {
   echo ("File is not writeable!");
}
?>

Output

File is not writeable!