$file = 'example.txt'; if(file_writable($file)){ echo 'The file is writable.'; } else{ echo 'The file is not writable.'; }
$dir = 'myfolder'; if(is_writable($dir)){ echo 'The directory is writable.'; } else{ echo 'The directory is not writable.'; }In the above example, we are checking if the directory "myfolder" is writable or not. Package/Library: The "file writable" function is a built-in function in PHP, so no external package or library is required.