PHP htmlspecialchars Function

What is htmlspecialchars Function?


In PHP, this function is used to convert special 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 htmlspecialchars($str, ENT_COMPAT);
echo "<br />";
echo htmlspecialchars($str, ENT_QUOTES);
echo "<br />";
echo htmlspecialchars($str, ENT_NOQUOTES);
Result :

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

In the above example the different quote styles are used to get the characters for the given html entities


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

PHP Topics

Ask Questions

Ask Question