How to strip the following html tags from user input in PHP? -


I do not want to use htmlentities () because I want to strip only 3 types of tags and allow all others I am These are to be stripped:

  - & lt; A hrefs ... - & lt; Scripts ... - & lt; Img src ...   

How can this be done?

  $ str = strip_tags ($ str, '& lt; a & gt; & lt; ; Scripts & gt; & lt; img & gt; ');   

However, if it is for security, it is not enough use a white parser and whitelist of allowed tags and attributes.

Otherwise I would & lt; Button onclick = "alert ('xss')" & gt; Hello! / code>, for example.

Comments