You can utilize the PHP htmlspecialchars_decode() capacity to change over the uncommon HTML substances, for example
&
, <
, >
and so on back to the typical characters for example (i.e. &
, <
, >
).. The htmlspecialchars_decode() work is inverse of the htmlspecialchars() work which changes over unique HTML characters into HTML substances. SOLUTION:
htmlspecialchars
(PHP 4, PHP 5, PHP 7)
htmlspecialchars - Convert special characters to HTML entities
Description
htmlspecialchars (string $ string [, int $ flags = ENT_COMPAT | ENT_HTML401 [, string $ encoding = ini_get ("default_charset") [, bool $ double_encode = TRUE]]]): string
Some characters have special meanings in HTML, and must be replaced by HTML entities to keep their meanings. This function returns a character string with these modifications. If you need all input substrings that are associated with named entities to be transformed, use the htmlentities () function.
We should look this exemple:
$my_str = "I'll come & <b>"get you"</b>.";
// Decode &, <, > and "
echo htmlspecialchars_decode($my_str);
// Decode &, <, >, " and '
echo htmlspecialchars_decode($my_str, ENT_QUOTES);
// Decode &, < and >
echo htmlspecialchars_decode($my_str, ENT_NOQUOTES);
if you want to improve the solution
comment to help the community
Post a Comment