I am including a textfile from a PHP file, using:
include("thesocalledfile.txt");
But when it prints out, it doesn't happear to show the whitespaces, \\n, etc.
When you are displaying text to a browser, you will need to append HTML formatting to it, or stick it inside a set of <pre></pre>
tags.
The simplest way to add in line breaks and so forth in php is nl2br .
<?php
echo nl2br("foo isn't\n bar");
?>
If you have plain text line breaks you can try
$fh = fopen("filename.txt", 'r');
$pageText = fread($fh, 25000);
echo nl2br($pageText);
you need the nl2br to wrap the text
You can also set up <pre></pre>
tags and output the file inside them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.