2

How would I make this actually display EXACTLY with PHP?

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

2 Answers2

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

This will display the message exactly as you typed it.

apokryfos
  • 38,771
  • 9
  • 70
  • 114
-1

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

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

Tishad Touhidul
  • 170
  • 4
  • 12