PHP is_writable() Function
In this chapter you will learn:
- Definition for PHP is_writable() Function
- Syntax for PHP is_writable() Function
- Parameter for PHP is_writable() Function
- Return for PHP is_writable() Function
- Note on PHP is_writable() Function
- Example - checks whether the specified file is writeable
Definition
The is_writable() function checks whether the specified file is writeable.
Syntax
PHP is_writable() Function has the following syntax.
is_writable(file)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
Return
This function returns TRUE if the file is writeable.
Note
The result of this function are cached. Use clearstatcache() to clear the cache.
Example
is_writeable() returns true if the string parameter is writeable.
For example, to check whether a file is writeable:
<?PHP/*from j a va 2s . 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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP link() Function
- Syntax for PHP link() Function
- Parameter for PHP link() Function
- Return for
- Note on PHP link() Function
- Example - creates a hard link from the existing target with the specified name link
Home » PHP Tutorial » PHP File Functions