I think the title is pretty elaborative! I tried to include few text files with the include function and they were included successfuly but they missed formatting i.e. the carriage return and other characters like tab, etc. I intend to solve this issue without using file , fopen , file get contents,etc because the include function requires much less resources than the above stated. So any bright ideas?
If I am understanding you right, try:
echo '<pre>'; include("text.txt"); echo '</pre>';
or
echo nl2br(file_get_contents("text.txt"));
Or similar. Remember that \n means nothing to HTML. <br>, however, does.
Or if all you want to output is the text document (i.e.: there is no HTML involved):
<?php header('Content-Type: text/plain'); readfile('textfile.txt');
Note that if you're simply trying to display the contents of files, include() shouldn't be used... [man]readfile/man or [man]file_get_contents/man are better matches as they don't attempt to evaluate the file for PHP code to execute.
EDIT: Ah, didn't see the end of zabmilenko's post... guess he pretty much covered what I was going to say.