$string="A 'quote' is <b>bold</b>";
echo $string;//output-->A 'quote' is bold
$string=htmlentities($string, ENT_QUOTES, "UTF-8");
echo $string;//output-->A 'quote' is <b>bold</b>
我的php版本是5.4.6
我想编码单引号和标记
答案 0 :(得分:0)
尝试htmlspecialchars
<?php
$string="A 'quote' is <b>bold</b>";
echo $string."<br/>";//output-->A 'quote' is bold
$string=htmlentities($string, ENT_QUOTES, "UTF-8");
echo $string."<br/>";//output-->A 'quote' is <b>bold</b>
$string=htmlspecialchars($string);
echo $string."<br/>";
?>