The htmlspecialchar() is the php function which is used to convert predefined characters like &,”,< etc. to HTML entities.
Some of the predefined characters are:
- & (ampersand) becomes &
- ” (double quote) becomes "
- ‘ (single quote) becomes '
- < (less than) becomes <
- > (greater than) becomes >
For Eg:
<?php
Output
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new;
?> Test
<a