How can PHP be used to prompt the user to open or save a file before it is downloaded?
When downloading a file using PHP, you can use the `header()` function to prompt the user to either open or save the file before it is downloaded. By setting the appropriate headers, you can specify the content type and disposition of the file, which will trigger the browser to display the download dialog box.
<?php
$file = 'example.pdf';
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
readfile($file);
exit;
?>