Returns whether a file is writable.
This function returns TRUE if PHP has write access to a specified file and FALSE if it does not. If the file does not exist FALSE is also returned.
<?php
$filename = "log.txt";
if (is_writable($filename)) {
print "File is writable";
$logfile = fopen($filename, "a");
} else {
print "Write access denied to $filename, or file does not exist!";
}
?> Write access denied to log.txt, or file does not exist! If the file does not exist, or user privileges of PHP do not permit writing to the file, is_writable() will return FALSE.