The htmlentities function in PHP is used to convert characters into corresponding HTML entities where applicable. It is used to encode user input on a website so that users cannot insert harmful HTML codes into a site.
The syntax of the htmlentities function is:
htmlentities ('string', [quote_style], [character_set])
[quote_style] is used to determine whether to convert double quotes and single quotes. Possible values include:
Value | Convert Single Quotes | Convert Double Quotes |
ENT_COMPAT | No | Yes |
ENT_QUOTES | Yes | Yes |
ENT_NOQUOTES | No | No |
ENT_COMPAT is the default if quote_style is not specified.
[character_set] is the character set to use.
Let's take a look at the example below:
Example
print htmlentities('<br>An example');
Result:
<br>An example
If you like this please Link Back to this article...
0 comments:
Post a Comment