Brian Brian - 5 months ago 11x
PHP Question

How to literally display echo contents in php

I'm looking to literally display the contents of echo or print instead of PHP processing the HTML contained within.

For example, if I have the following:

echo("<a href='$file'>$file</a> <br />\n");
the PHP parser will literally display all my files within a directory as links. What if I wanted to literally output the HTML tags without executing them so that would be displayed as plain text?



Instead of echo, use php function htmlentities inside a html code tag:

echo "<code>";
echo htmlentities("<a href='$file'>$file</a> <br />\n");
echo "</code>";