1. Go to this page and download the library: Download lastguest/ev 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/ */
lastguest / ev example snippets
function ∑($n,$c=0){static$r;is_callable($c)?$r[$n][]=$c:@array_walk($r[$n],'call_user_func',$c?:[]);}
// Bind callback to event "init"
∑('init', function(){
echo "Init event triggered!\n";
});
// Bind another callback to event "init"
∑('init', function(){
echo "Second handler for init triggered!\n";
});
// Bind callback to event "debug.event" and listen to passed parameters
∑('debug.event', function($idx,$params){
echo "Called debug.event[$idx] with parameters : ",print_r($params,true),"\n";
});
function ∑ ($event_name, $callback=null){
// The event handlers repository.
static $event_handlers;
if (is_callable($callback)) {
// We are binding a callback to an event, add $callback to the
// events handler repository.
$event_handlers[$event_name][] = $callback;
} else {
// When $callback is not a callable, then we are triggering the event.
// In this case, $callback will be our array of parameters to pass to event handlers
$params = $callback ? $callback : [];
// Walk all handlers binded to event $event_name and invoke them with the
// ($event_index, $params) parameters.
array_walk($event_handlers[$event_name],'call_user_func',$params);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.