How can meta tags be used to initiate automatic downloads in PHP?

Meta tags can be used to initiate automatic downloads in PHP by setting the content-disposition header to "attachment" and specifying the filename in the "filename" parameter. This will 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;
?>