Page 1 of 1

html_entity_decode() and < > characters

Posted: Tue Nov 03, 2009 8:12 am
by tiha
Hi,
I am trying to encode a string using html_entity_decode(). The string looks like this: "bla <bli> bla".
Unfortunately html_entity_decode() cuts out <bli> from the string and returns "bla bla". I tried using < > instead of < > but no change <bli> is cut out too. If submitting the string "bla <> bla" html_entity_decode() returns "bla <> bla".
Any suggestions please how I could make it leave "<bli>" unchanged?
Tiha

Re: html_entity_decode() and < > characters

Posted: Tue Nov 03, 2009 9:48 am
by xtiano77
Just a suggestion, but I think htmlspecialchars() & htmlspecialchars_decode() should work better for you.

Re: html_entity_decode() and < > characters

Posted: Tue Nov 03, 2009 9:51 am
by AbraCadaver
Well first, you can't decode < and > because they aren't coded. Second, it isn't stripping those, you just can't see <bli> in a browser because it interprets it as a tag. Try doing a var_dump() or view source of your page.

Re: html_entity_decode() and < > characters

Posted: Tue Nov 03, 2009 10:04 am
by tiha
Thank you for your replies. Will try htmlspecialchars() and report back.

To AbraCadaver: html_entity_decode() is actually stripping <bli> from my string, I looked in the source of the page and it was not there hidden as a tag.