What is the function "is_writable" in PHP and how can it be used to determine if a file can be written to a directory?

The function "is_writable" in PHP is used to determine if a file or directory is writable. To check if a file can be written to a directory, you can use this function to check the permissions of the directory. If the directory is writable, then you can write to it.

$directory = '/path/to/directory';

if(is_writable($directory)) {
    echo "Directory is writable, you can write to it.";
} else {
    echo "Directory is not writable, you cannot write to it.";
}