Output PHP Using Content-Type Text Plain - header("Content-Type: text/plain");

Gordon McNevin
29-12-2018 09:00:00

If you're like me and you just want to output basic text to the screen that is easy to read and format, then just using text/plain in PHP is a simple and effective solution!

To achieve this simply include the following line of code at the top of your pages before any other output...

<?php
header
("Content-Type: text/plain");
echo 
"This is pure text with a line break.\n";
echo 
"And this is another line.\n";
?>

Now you'll get basic text/plain output on your php pages with simple line breaks

Hope this helps!