Reputation: 121
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?
Thanks.
Upvotes: 1
Views: 729
Reputation: 80
'<' = <
'>' = >
echo ("<a href='$file'>$file</a> <br />\n");
or...
echo htmlspecialchars("<a href='$file'>$file</a> <br />\n");
Upvotes: 0
Reputation: 1887
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>";
Upvotes: 3