PHP is_writable() Function
❮ PHP Filesystem ReferenceExample
Check whether the specified filename is writable:
<?php
$file = "test.txt";
if(is_writable($file)) {
echo ("$file is writable");
}
else {
echo ("$file is not writable");
}
?>
The output of the code above could be:
test.txt is writable
Definition and Usage
The is_writable() function checks whether the specified filename is writable.
Note: The result of this function is cached. Use clearstatcache() to clear the cache.
Syntax
is_writable(file)
Parameter Values
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to check |
Technical Details
Return Value: | TRUE if the file is writable, an E_WARNING on failure |
---|---|
PHP Version: | 4.0+ |
❮ PHP Filesystem Reference