PHP code example of initphp / event-emitter

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

    

initphp / event-emitter example snippets



use InitPHP\EventEmitter\EventEmitter;

$events = new EventEmitter();

$events->on('hello', function ($name) {
    echo 'Hello ' . $name . '!' . PHP_EOL;
}, 99);

$events->on('hello', function ($name) {
    echo 'Hi ' . $name . '!' . PHP_EOL;
}, 10);

// Emit
$events->emit('hello', ['World']);