What are the best practices for handling permissions when exporting database files in PHP?

When exporting database files in PHP, it is important to handle permissions properly to ensure the security of the data. One best practice is to set restrictive permissions on the exported file to prevent unauthorized access. This can be achieved by using the PHP `chmod()` function to set the file permissions accordingly.

// Exporting database file
$exportedFile = 'exported_data.csv';
$data = 'your database data here';

// Write data to file
file_put_contents($exportedFile, $data);

// Set file permissions
chmod($exportedFile, 0600);