PHP HTTP下载头

PHP HTTP下载头,php,http,download,header,Php,Http,Download,Header,我试图用PHP生成一个HTML文件,并强制浏览器下载它。问题是,即使我生成了一个扩展名未知的文件,例如“.mail”,该文件也会显示在浏览器窗口中。我试图重写HTTP头,但服务器(PLESK)似乎忽略了它们: 以下是我的PHP代码: <?php header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="mail.html"'); header("Prag

我试图用PHP生成一个HTML文件,并强制浏览器下载它。问题是,即使我生成了一个扩展名未知的文件,例如“.mail”,该文件也会显示在浏览器窗口中。我试图重写HTTP头,但服务器(PLESK)似乎忽略了它们: 以下是我的PHP代码:

<?php 
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="mail.html"');
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//print_r($_POST);
switch ($_POST['radios']){
    case 1:

        include("1.include");

        print($_POST["editor1"]);

        include("1-foot.include");
        brake;
    case 2:
        brake;
    case 3:
        brake;
    case 4:
        brake;
}

?>

明白了:)在
侧注之前有1个空格-如果你输入错误并简单地复制它,刹车和断键是不一样的;)谢谢:D
Connection  
Keep-Alive
Content-Type    
text/html
Date    
Fri, 23 Oct 2015 22:06:41 GMT
Keep-Alive  
timeout=5, max=100
Server  
Apache
Transfer-Encoding   
chunked
X-Powered-By    
PleskLin
Quelltext anzeigen
Accept  
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding 
gzip, deflate
Accept-Language 
de,en-US;q=0.7,en;q=0.3
Cache-Control   
no-cache
Connection  
keep-alive
Cookie  
_pk_id.1.974f=82b4d2cf248e9b40.1420714194.2.1421423646.1420714194.; __atuvc=1%7C1%2C1%7C2
Host    
**********************
Pragma  
no-cache
Referer 
**********************
User-Agent  
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0