1. Html_entity_decode (): Converts an HTML entity to a character.
Eg:$str = "Just atest & & #039; Learn to use & #039; ";
echo Html_entity_decode ($STR);
echo "<br/>";
Echo Html_entity_decode ($str, ent_quotes);
echo "<br/>";
Echo Html_entity_decode ($str, ent_noquotes);
The output is as follows:
Just a Test & ' learn to use '
Just a Test & ' learn to use '
Just a Test & ' learn to use '
2. htmlentities (): Converts characters to HTML entities.
Eg:$str = "Just a Test & ' learn to use '";
Echo htmlentities ($str, Ent_compat);
echo "<br/>";
Echo htmlentities ($str, ent_quotes);
echo "<br/>";
Echo htmlentities ($str, ent_noquotes);
The output is as follows:
Just a Test & ' learn to use '
Just a Test & ' learn to use '
Just a Test & ' learn to use '
View the source code as follows:
Just a test & ' Learn to use ' <br/>
Just a test & & #039; learn to use& #039; <br/>
Just a test & ' Learn to use '
3.addslashes (): Adds a backslash before the specified predefined character
Predefined characters include: Single quotation mark ('), double quotation mark ("), backslash (\), NULL
By default, PHP instruction MAGIC_QUOTES_GPC is on, and automatically runs Addslashes () for all get, POST, and cookie data. Do not use Addslashes () for strings that have been MAGIC_QUOTES_GPC escaped, because this results in double-layer escaping. You can use the function GET_MAGIC_QUOTES_GPC () to detect this situation.
Eg:$str 3= "\ just a" \ "test";
Echoaddslashes ($str 3);
Output:
\ \ just a \ ' \ "Test
4.stripslashes (): Remove the backslash added by the addslashes function
Eg:$str 4= "\ \ Just a \ '" Test ";
Echo stripslashes ($str 4);
Output:
Just a ' "test
5, Htmlspecialchars (): Convert some of the predefined characters to HTML entities.
Predefined characters include:& (and number) become &
"(double quotes) become "
' (single quotes) become & #039;
< (less than) becomes <
> (greater than) becomes >
Eg:$str 5 = "Just atest & ' Learn to use '";
Echo Htmlspecialchars ($str 5, Ent_compat);
echo "<br/>";
Echo Htmlspecialchars ($str 5, ent_quotes);
echo "<br/>";
Echo Htmlspecialchars ($str 5, ent_noquotes);
Output:
Just a Test & ' learn to use '
Just a Test & ' learn to use '
Just a Test & ' learn to use '
&NBS P just a test & & #039; learn to use& #039; <br/>
just a test & ' Learn to use '
6, htmlspecialchars_decode (): Converts some of the predefined HTML entities to characters.
" becomes "(double quotes)
& #039; become ' (single quote)
< Become < (less than)
> becomes > (greater than)
eg: $str 6 = "Just atest & & #039; learn to use& #039; ";
echo htmlspecialchars_decode ($str 6);
Echo "<br/>";
Echo htmlspecialchars_decode ($str 6, ent_quotes);
Echo "<br/>";
Echo htmlspecialchars_decode ($str 6, ent_noquotes);
Output:
Just a Test & ' learn to use '
Just a Test & ' learn to use '
Just a Test & ' learn to use '
View Source code:
Just a Test & & #039; Learn to use & #039; <br/>
just a Test & ' learn to use ' <br/>
just a Test & & #039; Learn to use & #039;
So far, I think you should understand the basic trial of several functions.
Use of Htmlentities, Addslashes, Htmlspecialchars