PHP code example of sminnee / callbacklist

1. Go to this page and download the library: Download sminnee/callbacklist 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/ */

    

sminnee / callbacklist example snippets


use Sminnee\CallbackList\CallbackList;

$list = new CallbackList;
$list->add(function() { "this will get called"; });
$list->add(function() { "so will this"; });
$list->call();

// Or you can use it as a callable if you prefer
$list();

$list->add(function($greeting) { "$greeting, world!"; });
$list("Hello");

use Sminnee\CallbackList\CallbackList;

$list = new CallbackList;
$list->add(function() { return "this will get returned"; });
$list->add(function() { return "so will this"; });

// ["this will get returned", "so will this"]
var_dump($list());

// Clear the list
$list->clear();

// Or add a callback with a name
$list->add(function($greeting) { "$greeting, world!"; }, 'greeter');

// And then remove by that name
$list->remove('greeter');

// Return a single named callback
$list->get('greeter');

// Return everything as an array
$list->getAll();