It converts predefined characters to HTML entities. The predefined characters are:
- & (ampersand) becomes &
- ” (double quote) becomes "
- ‘ (single quote) becomes '
- < (less than) becomes <
- > (greater than) becomes >
Example
<?php echo htmlspecialchars("<a href='http://phpcodez.comt'>phpcode</a>"); ?>
Output
<a href=’http://phpcodez.comt’>phpcode</a>