Reputation: 155
I'm trying to output HTML into a textbox and not have it break the textbox.
I'd like it so in the textbox I could have HTML in there, such as spans, h1s, h2s, etc. Each time I try do this the textbox breaks.
I've tried: stripslashes(), decoding the html and re-encoding it. I'm sure there's a simple function that does this but I can't seem to find it.
Any help is appreciated.
Upvotes: 1
Views: 40
Reputation: 20806
As Seth suggests, you should use htmlentities()
.
This way, a string like this:
$str = htmlentities("A 'quote' is <b>bold</b>");
Will be converted to this:
$str = "A 'quote' is <b>bold</b>";
When outputted to the page, it will show <
properly as <
, etc.
Upvotes: 1