What alternative methods can be used in PHP to manage file permissions, especially for users who may not be familiar with changing chmod settings manually?

When managing file permissions in PHP, it can be challenging for users who are not familiar with changing chmod settings manually. One alternative method is to use the `chmod()` function in PHP, which allows you to change the file permissions programmatically. This function takes the file path and the desired permissions as parameters, making it easier to manage file permissions without needing to manually adjust settings.

<?php
$file = 'example.txt';
$permissions = 0644; // Set the desired permissions here

if (file_exists($file)) {
    chmod($file, $permissions);
    echo "File permissions updated successfully.";
} else {
    echo "File does not exist.";
}
?>