PHP code example of handmadeweb / hookable-actions-filters

1. Go to this page and download the library: Download handmadeweb/hookable-actions-filters 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/ */

    

handmadeweb / hookable-actions-filters example snippets

 php

use HandmadeWeb\ActionsAndFilters\Action;

// Eample function for test
function action_test($key){
    unset($_GET[$key]);
}

// Add a action callback to a function by name
Action::add('unset', 'action_test');
// Or

// Add a action callback to a closure function
Action::add('unset', function($key){
    action_test($key);
    // Or this closure function could just do unset($_GET[$key]);
});

// Execute the action, which in this example will unset $_GET['foobar']
Action::run('unset', 'foobar');

 php

use HandmadeWeb\ActionsAndFilters\Filter;

// Add a filter callback to a function by name
Filter::add('Test', 'ucfirst');

// Add a filter callback to a closure function
Filter::add('Test', function($value){
    return "{$value} {$value}";
});

// Will return Foobar Foobar
Filter::run('Test', 'foobar');