Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


More on LinuxToday


The New PHP 5 Features for Constructors and Destructors

Dec 23, 2010, 07:04 (0 Talkback[s])
(Other stories by Octavia Andreea Anghel)

"As you probably know, the new OOP features in PHP 5 bring a new perspective to PHP applications. In this article, you will see the new PHP 5 features regarding constructors and destructors, which are one of the most important aspects in any type of object-orientated class. As a reminder, 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.

"The article starts with a short overview of PHP 5 constructors, compared with the old fashion PHP 4. It continues with an explanation of writing constructors with or without parameters, restrictive constructors, overloading and PHP 5 destructors. At the end, you will be able to write almost any kind of constructor for your PHP 5 classes.

"PHP 5 vs. PHP 4 Constructors

"As a developer, each time you try to learn something new (a technology, a design pattern, a paradigm, etc.) you start by looking at what you used in the past and trying to identify the advantages of the new concept. This approach can tell you if using PHP 5 constructors is worth your time. To that end, consider the following comparison that explores why PHP 5 constructors are superior to PHP 4:"

Complete Story

Related Stories: