PHP code example of protonlabs / php-adblock-parser

1. Go to this page and download the library: Download protonlabs/php-adblock-parser 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/ */

    

protonlabs / php-adblock-parser example snippets


   $adblockEntries = [
       "||ads.example.com^",
       "@@||ads.example.com/notbanner^$~script",
   ];
   

   use Limonte\AdblockParser;

   $ruleAggregate = (new RuleAggregateFactory(new RuleFactory()))->createFromAdblockEntries($adblockEntries);
   

   (new RuleApplier())->shouldBlock("http://ads.example.com", $ruleAggregate); // true
   (new RuleApplier())->shouldBlock("http://non-ads.example.com", $ruleAggregate); // false