Outputting text/plain using header()
I have a script with the following code:
My question is... how can I force the header to print the output as plain text (as if it were just a text file that the user were viewing in their browser)? Right now with the code above, it is just prompting me to download the entire php file.
<?
$billetlist = "...";
$list = file($billetlist);
if ($_GET['view'] == "text") {
header("Content-type: text/plain; charset=utf-8");
foreach ($list as $num => $text) {
$split = preg_split("/\|/", $text);
printf("%s\t%s\n", $split[0], $split[1]);
}
return;
}
?>My question is... how can I force the header to print the output as plain text (as if it were just a text file that the user were viewing in their browser)? Right now with the code above, it is just prompting me to download the entire php file.
- Yes, I have already tried to google it.
- Yes, I have already read the PHP Manual.
- No, I am not a PHP Guru (nor do I claim to be one)... I'm sure my code is not the most efficient any of you have ever seen, but it works for me :)
