rtheunissen
rtheunissen

Reputation: 7435

How can I escape '<' and '>' dynamically in PHP?

For example, I have a string with value "CT.< S >" but in my HTML the is treated as a tag when echoed. Is there a function I can use to echo "CT. \< S\>" (for example) instead so that the HTML isn't treated as a tag?

Upvotes: 0

Views: 39

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

htmlspecialchars and htmlentities both do this.

Upvotes: 3

Related Questions