Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yehgdotnet/5b7562b46e6da6d05fc5b7ff35163bbb to your computer and use it in GitHub Desktop.
Save yehgdotnet/5b7562b46e6da6d05fc5b7ff35163bbb to your computer and use it in GitHub Desktop.
htmlspecialchars vs htmlentities
<?php
$s = $_GET['s'];
echo '<h1>htmlentities</h1>';
echo '<h1'.htmlentities($s,ENT_QUOTES).'>HELLO</h1>';
echo '<h2>htmlspecialchars</h2>';
echo '<h1'.htmlspecialchars($s,ENT_QUOTES).'>HELLO</h1>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment