What function in PHP can be used to force a file download instead of displaying it in the browser?
To force a file download instead of displaying it in the browser, you can use the PHP `header()` function to send the appropriate headers to the browser. By setting the `Content-Disposition` header to `attachment`, you can prompt the browser to download the file instead of displaying it.
<?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;
?>