I have a php script that opens a text file. Within this text file has several tags such as <br/>
in it.
What I want is the entire 30,000 line text file to print everything as text, including tags.
So no tags are enabled, and they're displayed as text instead.
Right now my code looks like:
<?php
$myfilename = "newer.txt";
if(file_exists($myfilename)){
echo html_entity_decode(file_get_contents($myfilename));
}
?>
And nothing changes. A lot of the tags such as <button>, <br>, and <image>
just take over the entire page.
I'm still looking for a simple way to stop tags, and view them as text.
You can do it like this:
<br>
In HTML, >
means > <
means <
So, replace < with <
; And > with >
You should use htmlentities:
echo htmlentities(file_get_contents($myfilename));
use htmlspecialchars
echo htmlspecialchars(file_get_contents($myfilename));