Skip to content
Ricardo Lopes edited this page Jan 16, 2015 · 2 revisions

php-html has a set of predefined tags allowed. if you wish to just keep that same set, just:

<?php
//create a new instance of the filter
$htmlFilter = new \HtmlFilter\Filter();

//get your dirty html on the table
$dirtyHtml = '<span>this should have nothing more<script>alert(1);</script></span>';

//and start you washing machine
$cleanHtml = $htmlFilter->filterHtml($dirtyHtml);

//your html should be squeaky clean now!
echo "<pre>$cleanHtml</pre>";

Clone this wiki locally