在php中将textarea的内容保存到文本文件中

在php中将textarea的内容保存到文本文件中,php,textarea,text-files,save-as,Php,Textarea,Text Files,Save As,单击“保存”按钮后,我想将文本区域的内容保存到计算机中的文本文件中。我的代码可以工作,但HTML代码也包含在文本文件中 这是我的密码: if(isset($_POST['submit_save'])) { $file = "output.txt"; $output = $_POST['output_str']; file_put_contents($file, $output); $text = file_get_contents($file); header("Content-type: a

单击“保存”按钮后,我想将文本区域的内容保存到计算机中的文本文件中。我的代码可以工作,但HTML代码也包含在文本文件中

这是我的密码:

if(isset($_POST['submit_save'])) {
$file = "output.txt";
$output = $_POST['output_str'];
file_put_contents($file, $output);
$text = file_get_contents($file);

header("Content-type: application/text");
header("Content-Disposition: attachment; filename=\"$file\"");
echo $text; 
} else {    
$_POST['output_str'] = "";
}
要保存的textarea内容示例:

The quick brown fox jumps over the lazy dog.
单击“保存”按钮后,“另存为”对话框将提示并将其另存为output.txt。 以下是output.txt中的内容:

The quick brown fox jumps over the lazy dog.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Save Textarea Content</title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>
.
.
. (all the way to </html>
</body>
</html>
敏捷的棕色狐狸跳过了懒狗。 保存文本区域内容 . . . (一路到
如何删除保存的文本文件中的html代码?

echo$text
更改为
die$text