use Event\Event; // Register an event called "hello" $event = new Event('hello'); // Define a function to say hello function sayHello() { echo "Hello world!"; } // Associate the "sayHello" function with "hello" event $event->addEvent('sayHello'); // Trigger the "hello" event to execute the associated function $event->triggerEvent('hello');
use Event\Event; // Register an event called "addNums" $event = new Event('addNums'); // Define a function to add two numbers function sum($num1, $num2) { echo $num1 + $num2; } // Associate the "sum" function with "addNums" event $event->addEvent('sum'); // Trigger the "addNums" event to execute the associated function with two parameters $event->triggerEvent('addNums', [2, 3]);The package library used in both examples is the "Event" package.