What steps can be taken to ensure that PHP scripts for file downloads do not interfere with the display of files in the browser?

When serving files for download in PHP, it's important to set the correct headers to prevent the file content from being displayed in the browser. To ensure that the file is downloaded instead of displayed, you can use the `Content-Disposition` header with the value `attachment`. This will prompt the browser to download the file instead of trying to display it.

<?php
$file = 'example.pdf';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
?>