php - How to convert quotes(',") from special char to general with other tags remaining special? -


in string have quotes(',") , < tags > . used

htmlspecialchars($str, ent_quotes);   

to convert single , double quote general text . unfortunately converting tags < , > . reason have

strip_tags("$desc","< b >< font >< >< u >< br >");  

those allowed tags displaying general < , > sign not working html tags .

in conclude , want display single , double quote regular text , allowed tags working html does.

thank you.

why don't run strip_tags() before htmlspecialchars() ?

sample:

<?php $input = '<b>allowed tag</b> " <font>not allowed tag</font>';  // xxx $tmp = htmlspecialchars($input, ent_quotes); $result = strip_tags($tmp, '<b>'); var_dump($result); // string(78) "&lt;b&gt;allowed tag&lt;/b&gt; &quot; &lt;font&gt;not allowed tag&lt;/font&gt;"  // improved $tmp = strip_tags($input, '<b>'); $result = htmlspecialchars($tmp, ent_quotes); var_dump($result); // string(53) "&lt;b&gt;allowed tag&lt;/b&gt; &quot; not allowed tag" 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -