A simple dynamic hook system for PHP. Very useful.
<?php
include('hooks.class.php');
$h = new Hooks();
?>
You can use hooks so easy! Look it.
//create hook (without args)
$h->here('namehook');
//create hook (with args)
$h->here('namehook1', array('arg1', 'arg2'));
//standard function
$h->register('namehook', 'default_function');
//will be added on hook
function default_function ($args)
{
echo 'Hello!';
}
//anonymous function
$h->register('namehook', function ($args) {
echo 'Hello!';
});
class Class {
//standard function
$h->register('namehook', 'default_function', $this);
//will be added on hook
function default_function ($args)
{
echo 'Hello!';
}
}
//selected function
$h->remove('namehook', 'default_function');
$h->remove('namehook');