html_entity_decode() and < > characters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tiha
Forum Newbie
Posts: 2
Joined: Tue Nov 03, 2009 8:05 am

html_entity_decode() and < > characters

Post 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
xtiano77
Forum Commoner
Posts: 72
Joined: Tue Sep 22, 2009 10:53 am
Location: Texas

Re: html_entity_decode() and < > characters

Post by xtiano77 »

Just a suggestion, but I think htmlspecialchars() & htmlspecialchars_decode() should work better for you.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: html_entity_decode() and < > characters

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
tiha
Forum Newbie
Posts: 2
Joined: Tue Nov 03, 2009 8:05 am

Re: html_entity_decode() and < > characters

Post 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.
Post Reply