Login   Register  
PHP Classes
elePHPant
Icontem

File: defer-example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ralf Mike Pretzlaw  >  Defer  >  defer-example.php  >  Download  
File: defer-example.php
Role: Example script
Content type: text/plain
Description: Exmaples
Class: Defer
Defer executing of code to emulate final functions
Author: By
Last change:
Date: 1 year ago
Size: 380 bytes
 

Contents

Class file image Download
<?php

require_once 'Defer.php';

function 
foo() {
    
$bar "some-handle";

    
$defer = new Defer();
    
$defer->nullify($bar);

    echo 
$bar PHP_EOL;
}

foo();

function 
baz(&$x) {

    
$defer = new Defer();
    
$defer->run(function () use(&$x) {
            echo 
" rocks!" PHP_EOL;
            
$x null;
        });

    echo 
$x;
}

$x "defer";
baz($x);
var_dump($x);