Reputation: 1
I am having problem in making html code in a string written PHP from appearing as an html element on the web page. What i really want is to make the html code to show as text on the page. Is there a way to preserve the html code in a string as string on the page?
Upvotes: 0
Views: 702
Reputation:
If you are displaying Html submitted by an end user, take it a step further and use http://htmlpurifier.org/ or http://tidy.sourceforge.net/ to remove potential submitted malicious code. For example, prevent some one from entering javascript, or php code, etc. That could in turn be used to cause trouble.
Upvotes: 0
Reputation: 20889
Use htmlentities().
It changes things like <
and >
to <
and >
.
Visually, they're exactly the same to the user but it won't be parsed as HTML tags.
Upvotes: 4