How can headers be manipulated in PHP to ensure secure file access?

To ensure secure file access in PHP, headers can be manipulated using the `Content-Disposition` header to force the browser to download files instead of executing them. This prevents the execution of potentially harmful scripts that may be included in the file.

<?php
$file = 'example.pdf';
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
readfile($file);
exit;
?>