PHP htmlentities Function

What is htmlentities Function?


In PHP, this function is used to convert all applicable characters to HTML entities.



In the above syntax "string" specifies the text to decode, "quotestyle" specifies how to decode single and double quotes,"characterset" specifies the character set to be used.

Example :

$str = "Hiox & 'India'";
echo htmlentities($str, ENT_COMPAT);
echo "<br />";
echo htmlentities($str, ENT_QUOTES);
echo "<br />";
echo htmlentities($str, ENT_NOQUOTES);
Result :

Hiox & 'India'
Hiox & 'India'
Hiox & 'India'

In the above example for string, the diffrent quote styles are used to get the html entities for the given characters


Please use "View Source" to know the exact output of the function

PHP Topics

Ask Questions

Ask Question