Skip to content Skip to sidebar Skip to footer

Php How To Echo Without Html Tags

I have a sort of system where everybody can type whatever he wants. Though, they can also seem to use tags like , etc. How cou

Solution 1:

To make the HTML display as written, you need to "escape" the special characters &, < and > using htmlspecialchars().

Alternatively, you could remove all the tags and display the remaining text using strip_tags()


Solution 2:

You may try :

echo htmlspecialchars('<a href="http://www.google.com">Google</a>');

More info here


Solution 3:

Just use htmlentities on the string you want to print


Solution 4:

the special charcaters or the tags are treayted as different elements. before inserting the text in the database you can use htmlspecialcharacters($string_to_be_inserted) to escape the html tags.

All the html tags will get removed and only the text will be inserted in the database.

hope this helps


Solution 5:

You can also use HTMLPurifier to strip out unwanted HTML tags from your user input


Post a Comment for "Php How To Echo Without Html Tags"