<?php require_once 'Delegate.php'; ?>
----------------------------------USAGE SINGLE------------------------------------
<?php
// Testing function
function test () { echo "testing";}
// Testing Class
class Dog { protected $_name = 'charlie'; public function bark () { echo $this->_name; }}
// Testing Instance
$mydog = new Dog();
// Creating Delegate to add each one individually
$processruns = new Delegate();
$processruns->add(function() { echo "hello"; });
$processruns->add(function() { echo "world"; });
$processruns->add(array($mydog, 'bark'));
$processruns->add('test');
$processruns->execute();
?>
----------------------------------USAGE Array------------------------------------
<?php
$processruns2 = new Delegate();
$processruns2->add(array(function() { echo "hello"; },
function() { echo "world"; },
array($mydog, 'bark'),
'test'));
$processruns2->execute();
?>
|