-4
            $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

我想编码单引号和标签

4

1 回答 1

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/>";          
?>
于 2013-11-09T07:03:25.620 回答