PHP Classes / HTML Sanitizer

Remove unsafe tags and attributes from HTML code

HTML Sanitizer PHP Class

This class can be used to remove unsafe tags and attributes from HTML code. It takes a string with HTML code and strips all the tags that do not make part of a list of safe tags. That list of safe tags is defined as a private class variable. There are some functions to allow usually unsafe tags like script, style, object, embed, etc.. The class can also remove unsafe tag attributes, such as those that define Javascript code to handle events. The links href attributes also gets special treatment to remove URLs that trigger Javascript code execution and line breaks.

Similar PHP Classes

Search in PHP Classes

Filter by tags