What is the significance of the chmod command in relation to file permissions in PHP scripts?
The chmod command in PHP is used to set the file permissions of a file or directory. This command is important because it allows you to control who can read, write, or execute a file, which is crucial for security and access control in PHP scripts.
// Set file permissions using chmod
$file = 'example.txt';
$permissions = 0644; // Set read and write permissions for owner, read permissions for group and others
if (file_exists($file)) {
chmod($file, $permissions);
echo "File permissions set successfully.";
} else {
echo "File does not exist.";
}