require_once('path/to/HTMLPurifier.auto.php'); $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); $clean_html = $purifier->purify($input_html);
require_once('path/to/HTMLPurifier.auto.php'); $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.Strict', true); $config->set('Attr.AllowedFrameTargets', array('_blank')); $purifier = new HTMLPurifier($config); $clean_html = $purifier->purify($input_html);In these examples, the HTMLPurifier library is being used to clean HTML input. The first example uses the default settings, while the second example shows how you can customize the settings to allow additional HTML tags or attributes. Overall, PHP HTML Clean is a useful library to have in your toolkit if you are developing web applications or working with user-generated content. With its powerful cleaning capabilities, it can help ensure that your application is secure and safe for users to interact with.