Login   Register  
PHP Classes
elePHPant
Icontem

Defer: Defer executing of code to emulate final functions

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2012-12-16 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 333 All time: 6,338 This week: 1,947Up
Version License PHP version Categories  
defer 1.0BSD License5.3PHP 5, Language
Description Author  

This class can defer executing of code to emulate final functions.

It can register functions to be called when the object is destroyed, so the functions are only executed when the current function or scope ends and the class destructor is called.

The class can also register references to variables that will also be unset by the class destructor when the current function or scope ends.

Innovation Award  
PHP Programming Innovation award nominee
January 2013
Number 4
The finally construct introduced in PHP 5.5 allows developers to defined some code that will always be executed regardless if an exception is thrown.

This class implements a different approach to achieve the same purpose of finally, except that it works even in older PHP versions.

It uses cleverly a class destructor function to execute code that will always be executed when an object is destructed while PHP is exiting the function or scope on which an object of this class was created.

Manuel Lemos
Picture of Ralf Mike Pretzlaw
Name: Ralf Mike Pretzlaw <contact>
Classes: 3 packages by
Country: Germany Germany
Age: 30
All time rank: 1911124 in Germany Germany
Week rank: 1723 Up86 in Germany Germany Up
Innovation award
Innovation award
Nominee: 2x

  Files folder image Files  
File Role Description
Plain text file Defer.php Class Defer class (unset variable and run function later)
Accessible without login Plain text file defer-example.php Example Exmaples

 Version Control Unique User Downloads Download Rankings  
 0%Total:333All time:6,338
 This week:0This week:1,947Up
 User Comments (1)