header("Content-Type: application/octet-stream"); 
$quan=$_GET['quan'];
$ua = $_SERVER["HTTP_USER_AGENT"]; 
$filename = "100yuan.txt"; 
$encoded_filename = urlencode($filename); 
$encoded_filename = str_replace("+", "%20", $encoded_filename); 
if (preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']) ) { 
    header('Content-Disposition:  p_w_upload; filename="' . $encoded_filename . '"'); 
} elseif (preg_match("/Firefox/", $_SERVER['HTTP_USER_AGENT'])) { 
   // header('Content-Disposition: p_w_upload; filename*="utf8' .  $filename . '"');
    header('Content-Disposition: p_w_upload; filename*="' .  $filename . '"'); 
} else { 
    header('Content-Disposition: p_w_upload; filename="' .  $filename . '"'); 
}
echo '您已领取100元现金券。现金券编码是:'.$quan;



web页面生成TXT文件供另存为下载


web页面生成TXT文件供另存为下载_第1张图片