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) "<b>allowed tag</b> " <font>not allowed tag</font>" // improved $tmp = strip_tags($input, '<b>'); $result = htmlspecialchars($tmp, ent_quotes); var_dump($result); // string(53) "<b>allowed tag</b> " not allowed tag"
Comments
Post a Comment