Home >Backend Development >PHP Tutorial >php is_writable Whether the function file can be written_PHP tutorial
The following is about whether the is_writable file can be read and written.
The following is about whether the is_writable file can be read and written.
is_writable
(PHP 4, PHP 5)
is_writable - tells whether filename is writable
Description
boolean is_writable (string $filename)
Returns TRUE if the file exists and is writable. The filename argument may be a directory name, allowing you to check if the directory is writable.
Keep in mind that PHP can access this file with the user ID of the web server running (usually 'who'). Safe mode restrictions are not taken into account.
Parameters
File name
The name of the file being checked.
Return value
Returns TRUE if the file exists and is writable.
Example
Example #1 is_writable() example
$filename = 'test.txt';
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
?>