How to use htmlspecialchars decode in PHP
In this article I will explain how htmlspecialchars_decode() function can be used in PHP.
htmlspecialchars_decode() function in PHP
- The htmlspecialchars_decode() function is used to convert some predefined HTML entities to characters.
- The htmlspecialchars_decode() function is the opposite of hrmlspecialchars().
-
some HTML entities that will be decoded are:
- & becomes & (ampersand)
- " becomes " (double quote)
- ' becomes ' (single quote)
- < becomes < (less than)
- > becomes > (greater than)
Syntax
htmlspecialchars_decode(string,quotestyle) |
Parameter
- string string is required parameter. it is determine string to be decode.
-
quotestyle quotestyle is optional parameter. Specifies how to decode single and double quotes. some available quote styles are:
- ENT_COMPAT - This is default value. It's decode only double quotes.
- ENT_QUOTES - It's decode double and single quotes.
- ENT_NOQUOTES - It does not decode any quotes.
Example
The following example show to how the htmlspecialchars_decode() function can be used in PHP.
<html>
<body>
<h3 style="color: darkseagreen;">htmlspecialchars_decode() function example in PHP</h3>
<?php
$input_string = "© C-sharpcorner.com";
echo 'After decoding : '.htmlspecialchars_decode($input_string) .'<br>';
$input_string = "<table><br/>We are learning php</td><br></tr><br></table><br>";
echo 'After decoding : '.htmlspecialchars_decode($input_string) .'<br>';
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here