PHP Classes

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    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 341 All time: 7,069 This week: 455Up
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: 40
All time rank: 2087129 in Germany Germany
Week rank: 321 Up11 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:341
This week:0
All time:7,069
This week:455Up
User Ratings User Comments (1)
 All time
Utility:85%StarStarStarStarStar
Consistency:85%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1411