What function in PHP can be used to set the access permissions for a file?

To set the access permissions for a file in PHP, you can use the `chmod()` function. This function takes two parameters: the file path and the permissions to set. The permissions can be specified using octal notation, where each digit represents the permissions for the owner, group, and others respectively.

$file = 'example.txt';
$permissions = 0644; // Owner can read and write, others can only read
if (file_exists($file)) {
    chmod($file, $permissions);
    echo "Permissions set successfully!";
} else {
    echo "File does not exist.";
}