//下载文件 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教學有興趣的朋友有幫助。