Pages

PHP htmlentities Function

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:
ValueConvert Single QuotesConvert Double Quotes
ENT_COMPATNoYes
ENT_QUOTESYesYes
ENT_NOQUOTESNoNo

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:
&lt;br&gt;An example

If you like this please Link Back to this article...



0 comments:

Post a Comment