Brian Brian - 2 years ago 75
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?


Answer Source

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>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download