Testing for write permission : is_writable « File Directory « PHP






Testing for write permission

 
$log_file = '/var/log/users.log';
if (is_writeable($log_file)) {
    $fh = fopen($log_file,'ab');
    fwrite($fh, $_SESSION['username'] . ' at ' . strftime('%c') . "\n");
    fclose($fh);
} else {
    print "Can't write to log file.";
}
  
  








Related examples in the same category

1.is_writeable
2.is_writable() tells you whether you can write to a file.