This is a simple question, but I'm a newbie, so please forgive my simple question.
Is there an easy way to reverse the filter effect FILTER_SANITIZE_SPECIAL_CHARS? If not, how would you cancel it. Please do not just say regular expressions, actually suggest how to do this. To be clear, I am not trying to change the line.
Here is a sample code to help explain what I want to do:
/*** a string with tags ***/
$string = "<li><script>!@#$%^&*\n\'#foo</script><br><p /><li />";
/*** sanitize the string ***/
$x = filter_var($string, FILTER_SANITIZE_SPECIAL_CHARS);
echo $x . "<br>\n";
/*** I want this to output <li><script>!@#$%^&*\n\'#foo</script><br><p /><li /> ***/
echo htmlspecialchars_decode($x);
/*** instead it outputs: <li><script>!@#$%^&* \'#foo</script><br><p /><li /> ***/
Any ideas will be appreciated. Thanks in advance.
source
share