如何在PHP中显示htmlspecialchars

如何在PHP中显示htmlspecialchars,php,htmlspecialchars,Php,Htmlspecialchars,如何使用PHP使其真正显示出来 $answer=<script>alert(It converts to HTML.)</script> echo "The function is: htmlspecialchars ($answer)." $answer=alert(它将转换为HTML。) echo“函数是:htmlspecialchars($answer)。” $answer=“警报(它转换为HTML)。” echo“函数为:htmlspecialchars”。$

如何使用PHP使其真正显示出来

$answer=<script>alert(It converts to HTML.)</script> 
echo "The function is: htmlspecialchars ($answer)."
$answer=alert(它将转换为HTML。)
echo“函数是:htmlspecialchars($answer)。”
$answer=“警报(它转换为HTML)。”


echo“函数为:htmlspecialchars”。$answer

$variable=这是您的确切代码吗?我正试图在页面上以完全相同的方式显示您的预期输出是什么?
$variable = <<<'EOS'
$answer=<script>alert(It converts to HTML.)</script> 
echo "The function is: htmlspecialchars ($answer)."
EOS;
echo htmlspecialchars($variable);