Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php event listener

/*
 Example 1: 
 event::bind('blog.post.create', function($args = array())
 {
    mail('myself@me.com', 'Blog Post Published', $args['name'] . ' has been published');
});

 Example 2: 
 event::trigger('blog.post.create', $postInfo);
*/

class event
{
    public static $events = array();

    public static function trigger($event, $args = array())
    {
        if(isset(self::$events[$event]))
        {
            foreach(self::$events[$event] as $func)
            {
                call_user_func($func, $args);
            }
        }

    }

    public static function bind($event, Closure $func)
    {
        self::$events[$event][] = $func;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: Target class [AppHttpControllersAdminUserController] does not exist. larvel 8 
Php :: php nested array 
Php :: file_get_contents with url 
Php :: my xampp 
Php :: Laravael Blog Project 
Php :: laravel http response with cookie 
Php :: what does = mean in php 
Php :: image not displaying in laravel 
Php :: order item add hook WooCommerce admin panel 
Php :: authenticate user with phone laravel 
Php :: php forech pdo 
Php :: remove column laravel migration 
Java :: basic hello world program in java 
Java :: The import javax.persistence cannot be resolved 
Java :: getcolor deprecated 
Java :: what are the hibernate dependencies 
Java :: java android show toast 
Java :: java stream find specific element 
Java :: java convert bytes to string 
Java :: base64 decode java 
Java :: error: cannot find symbol@javax.annotation.Generated( 
Java :: print list in java 8 
Java :: java wait 
Java :: java delete directory 
Java :: jframe add label java 
Java :: InetAddress.getByAddress example 
Java :: java reverse value of boolean 
Java :: CellStyle change backgroung color java 
Java :: joptionpane.showmessagedialog 
Java :: void set method using collections 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =