I have made function like below to remove html tags and special characters from the string.
function input_filter_data($data) {
$data= trim($data);
$data= stripslashes($data);
$data= htmlspecialchars($data);
$data= strip_tags($data);
return $data;
}
and I am trying to use it like below
$affiliate_id =input_filter_data("Hello <b><i>world!</i></b>","<i>");
echo $affiliate_id;
But its giving me same result like
Hello <b><i>world!</i></b>","<i>
But if I use simple like
echo strip_tags("Hello <b><i>world!</i></b>","<i>");
then its removing all html tags from string.
I am not getting idea why its happening like this, let me know if anyone here can help me for solve the puzzle.
Thanks!
CodePudding user response:
It could help to debug what each step of input_filter_data
does: after calling htmlspecialchars
, the string does not contain any markup, but solely escaped markup. strip_tags
won't perform any change on such a input