如何在 header 中传递多个文件扩展名参数?

How can I pass multiple file extensions parameter in header?

我有不同扩展名的文件,那么如何在一个文件中定义多个扩展名header。例如

 header("Content-type: application/xml"); 
 header("Content-type: application/txt");

有没有可能在单个 header 中定义这样的东西

 header("Content-type: application/xml txt"); 

提前感谢您的建议

如果您想下载任何类型的文件,您可以使用 application/octet-stream.

header('Content-Type: application/octet-stream');

// 例如,这将下载任何类型的文件

 header('Content-Description: File Transfer');
 header('Content-Type: application/octet-stream');
 header('Content-Disposition: attachment; filename="' . basename($file) . '"');
 header('Expires: 0');
 header('Cache-Control: must-revalidate');
 header('Pragma: public');
 header('Content-Length: ' . filesize($file));
 readfile($file);