What are the alternative methods to set file permissions in PHP other than using CHMOD?

When setting file permissions in PHP, an alternative method to using CHMOD is to use the `chmod()` function. This function allows you to set the permissions of a file or directory using an octal number that represents the desired permissions.

// Set file permissions using chmod() function
$filename = 'example.txt';
$permissions = 0644; // Set read and write permissions for owner, read permissions for group and others
if (file_exists($filename)) {
    chmod($filename, $permissions);
    echo "File permissions set successfully.";
} else {
    echo "File does not exist.";
}