PHP code example of athoshun / html-filter

1. Go to this page and download the library: Download athoshun/html-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

athoshun / html-filter example snippets




$config = new AthosHun\HTMLFilter\Configuration();
$config->allowTag("p")
       ->allowAttribute("a", "title")
       ->allowAttribute("a", "href", "|^https?://.*\$|");

$filter = new AthosHun\HTMLFilter\HTMLFilter();

$html = <<<HTML
Lorem ipsum <em>dolor</em> sit amet
<p>
    Consectetur <a href="http://example.com" title="hey!">adipisicing</a>
    <a href="javascript:alert(42)" onclick="alert(42)">elit</a>.
</p>
HTML;

print $filter->filter($config, $html);