PHP htmlentities only for special chars, not for html tags

by Subramanian 2014-07-30 15:24:26

PHP htmlentities only for special chars, not for html tags :

If you want to change special char or any maths symbols with html tags to htmlentities without affect the html tags then use the below line of code in php.
 
htmlspecialchars_decode( htmlentities( $str, ENT_NOQUOTES, 'UTF-8', false ), ENT_NOQUOTES );

Example :
<?php
$str = "<b>GvSubhu</b> °";
echo htmlspecialchars_decode( htmlentities( $str, ENT_NOQUOTES, 'UTF-8', false ), ENT_NOQUOTES );
?>
Output :
 
<b>GvSubhu</b> &deg;
705
like
0
dislike
0
mail
flag

You must LOGIN to add comments