UTF-8 HTML encoding : htmlspecialchars « HTML « PHP





UTF-8 HTML encoding

 
<?php
$encoded_name = htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8');
$encoded_dinner = htmlentities($_POST['dinner'], ENT_QUOTES, 'UTF-8');
?>
  
  

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.Escaping HTML entities