htmlspecialchars() function converts a select few characters in the context of HTML into their equivalent HTML entities. : htmlspecialchars « HTML « PHP






htmlspecialchars() function converts a select few characters in the context of HTML into their equivalent HTML entities.

 
Its syntax is: string htmlspecialchars (string string)

The htmlspecialchars() function currently only converts the following characters:

&   becomes &amp
""  becomes &quot
<   becomes &lt;
>   becomes &gt


<?
$user_input = "<<enough>> & !";
$conv_input = htmlspecialchars($user_input);
print $conv_input;
?>
  
  








Related examples in the same category

1.htmlspecialchars.php
2.Escaping HTML entities
3.UTF-8 HTML encoding