Escaping HTML entities : htmlspecialchars « HTML « PHP






Escaping HTML entities

 
<?php
$html = "<a href='fletch.html'>Stew's favorite movie.</a>\n";
print htmlspecialchars($html);                
print htmlspecialchars($html, ENT_QUOTES);    
print htmlspecialchars($html, ENT_NOQUOTES);
?>
  
  








Related examples in the same category

1.htmlspecialchars() function converts a select few characters in the context of HTML into their equivalent HTML entities.
2.htmlspecialchars.php
3.UTF-8 HTML encoding