The New Features in PHP 5 Constructors and Destructors
Constructors and destructors are among the most important functions in any type of object-orientated class. In PHP, the new OOP features in PHP 5 offer a number of advantages over PHP 4 when you use constructor and destructor functions. In her PHPBuilder article The New PHP 5 Features for Constructors and Destructors, Octavia Andreea Anghel introduces PHP 5 constructors and destructors, comparing them with the old PHP 4 constructors and explaining how to write them for various uses.
First, she provides a refresher of the functions:
... a constructor is a special function of a class that is automatically executed whenever an object of a class gets instantiated. A destructor is a special function of a class that is automatically executed whenever an object should be destroyed.
By the end of the article, you'll be able to write almost any kind of constructor for your PHP 5 classes.
Read the full story at PHPBuilder:
The New PHP 5 Features for Constructors and Destructors
Originally published on https://www.developer.com.
This article was originally published on December 29, 2010