//下载文件 header('Content-Type:application/octet-stream'); if(preg_match('/MSIE/',$_SERVER['HTTP_USER_AGENT'])){ header('Content-Disposition:attachment;filename="'.str_replace("+","20%",urlencode($newFileName)).'"'); }else if(preg_match('/Firefox/',$_SERVER['HTTP_USER_AGENT'])){ header('Content-Disposition:attachment;filename=*"utf8'.$newFileName.'"'); }else{ header('Content-Disposition:attachment;filename="'.$newFileName.'"'); }
以上就介绍了PHP下载txt文件到浏览器,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。