What browser compatibility considerations should be taken into account when implementing file downloads with PHP?

When implementing file downloads with PHP, it is important to consider browser compatibility issues. Different browsers may handle file downloads differently, so it is important to set appropriate headers to ensure the file is downloaded correctly. Additionally, using the correct content type and content disposition headers can help ensure that the file is downloaded instead of displayed in the browser.

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