How can PHP scripts be used to change file permissions on a server?
To change file permissions on a server using PHP scripts, you can use the `chmod()` function. This function allows you to change the permissions of a file or directory by specifying the desired permissions in numeric format. Make sure to have the necessary permissions to modify the file or directory.
<?php
$file = 'example.txt';
$permissions = 0644; // Example permission value
if (file_exists($file)) {
chmod($file, $permissions);
echo "File permissions changed successfully.";
} else {
echo "File does not exist.";
}
?>