Faced a problem, I don’t know how to remove html tags ... The bottom line is that on my site you can send messages and the text of the message is written to the database, and then gets. And if you use tags like: <div> </div> in the message, they are perceived as html tags, not text. They seem to be replaced by &lt; and &gt;

I write the site in php.

    1 answer 1

    htmlentities ()

     $html = '<div> =) </div>'; $html = htmlentities( $html ); echo $html; // -> &lt;div&gt; =) &lt;/div&gt; 
    • Thanks, it works, but something is not very ... I put the whole message in this function, and this is what happens to it:> &acirc;&icirc;&ograve; &egrave;&ntilde;&iuml;&icirc;&euml;&uuml;&ccedil;&oacute;&eacute; &yacute;&ograve;&icirc;&ograve; &ecirc;&icirc;&auml;)) &acirc;&icirc;&ograve; &egrave;&ntilde;&iuml;&icirc;&euml;&uuml;&ccedil;&oacute;&eacute; &yacute;&ograve;&icirc;&ograve; &ecirc;&icirc;&auml;)) &acirc;&icirc;&ograve; &egrave;&ntilde;&iuml;&icirc;&euml;&uuml;&ccedil;&oacute;&eacute; &yacute;&ograve;&icirc;&ograve; &ecirc;&icirc;&auml;)) > &lt;div id=&quot;new_mail&quot;&gt; &acirc;&eth;&icirc;&auml;&aring; &aacute;&ucirc; &eth;&icirc;&aacute;&egrave;&ograve;)) &lt;/div&gt; &lt;div id=&quot;new_mail&quot;&gt; &acirc;&eth;&icirc;&auml;&aring; &aacute;&ucirc; &eth;&icirc;&aacute;&egrave;&ograve;)) &lt;/div&gt; - Lgunchik
    • Everything, I found the answer. You just need to use htmlentities() , and htmlspecialchars() , then everything is fine. - Lgunchik