The is_writable() function checks whether the specified file is writeable.
PHP is_writable() Function has the following syntax.
is_writable(file)
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
This function returns TRUE if the file is writeable.
The result of this function are cached. Use clearstatcache() to clear the cache.
is_writeable() returns true if the string parameter is writeable.
For example, to check whether a file is writeable:
<?PHP/* www. ja v a2 s.c o m*/
$filename = 'c:\boot.ini'; // Windows
// $filename = '/etc/passwd'; // Unix
if (is_writeable($filename)) {
print 'File writeable!';
} else {
print 'File not writeable!';
}
?>
The code above generates the following result.