PHP htmlspecialchars_decode Function

What is htmlspecialchars_decode Function?

Explanation

In PHP, this function is used to convert special HTML entities back to characters.

Syntax:


htmlspecialchars_decode(string,quotestyle)

In the above syntax "string" specifies the text to decode, "quotestyle" specifies how to decode single and double quotes,some of the characters are that are converted are &= "&", "= "" ", '= "'", <= "<", >= ">".

Example :


<html>
<body>
<?php
$str = "Hiox & amp; & #039;India& #039;";
echo htmlspecialchars_decode($str, ENT_COMPAT);
echo "<br />";
echo htmlspecialchars_decode($str, ENT_QUOTES);
echo "<br />";
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
</html>
</body>
Result :
Hiox & 'India'
Hiox & 'India'
Hiox & 'India'

In the above example the diffrent quote styles are used to get the characters from the html entities.

NOTE:


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

PHP Topics


Ask Questions

Ask Question