PHP Classes
elePHPant
Icontem

Defer: Defer executing of code to emulate final functions

Recommend this page to a friend!
  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 (3 years ago) RSS 2.0 feedStarStarStarStar 67%Total: 338 All time: 6,704 This week: 935Up
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
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:338
This week:0
All time:6,704
This week:935Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:67%StarStarStarStar
Rank:517