Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sdwrage  >  Delegate  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example of the usage
Class: Delegate
Manage and call closures and callback functions
Author: By
Last change:
Date: 5 years ago
Size: 1,000 bytes
 

Contents

Class file image Download
<?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();
?>