How can PHP be used to force the "Save As" dialog for file downloads in different browsers?

To force the "Save As" dialog for file downloads in different browsers using PHP, you can set the appropriate headers in the response. By setting the Content-Disposition header to "attachment", you can prompt the browser to show the "Save As" dialog instead of trying to display the file in the browser window.

<?php
$file = 'path_to_your_file.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;
?>