如何在PHP中显示htmlspecialchars

时间:2017-03-12 06:07:51

标签: php htmlspecialchars

我如何使用PHP真正显示它?

$answer=<script>alert(It converts to HTML.)</script> 
echo "The function is: htmlspecialchars ($answer)."

3 个答案:

答案 0 :(得分:0)

对你的问题更加苛刻。这个脚本你想要什么?你对php的问题是什么?

$answer = "<script>alert(It converts to HTML.)</script>"
echo "The function is: htmlspecialchars (". $answer .")." //something like this? or htmlspecialchars is a php function?

答案 1 :(得分:0)

$answer = "<script>alert(It converts to HTML.)</script>"

echo "The function is: htmlspecialchars".$answer;

答案 2 :(得分:0)

$variable = <<<'EOS'
$answer=<script>alert(It converts to HTML.)</script> 
echo "The function is: htmlspecialchars ($answer)."
EOS;
echo htmlspecialchars($variable);

这将完全按照您键入的内容显示消息。