Linux Today: Linux News On Internet Time.

PHP V5 and Object-Oriented Programming

Nov 15, 2008, 18:02 (0 Talkback[s])
(Other stories by John Mertic)

[ Thanks to jmalasko for this link. ]

"When PHP V5 was released in 2004, it was a giant leap forward compared to what PHP V4 provided in regards to object-oriented programming (OOP) and design. It added several needed improvements, such as class visibility, proper constructors and destructors, type hinting, and a class-reflection API. It opened the door for advanced objected-oriented programming in PHP, and allowed you to implement many design patterns much easier, along with better design classes and APIs.

"In PHP V5.3, many incremental additions have been made to enhance OOP. These improvements have been in the realm of syntax additions and performance improvements. To begin, let's look at the new features available with static methods and members.

"Improved static method and member handling
One useful addition made in PHP V5 was the ability to specify a method or member of a class as static (PHP V4 did support static access to methods and members of class, but not the ability to specify that the method or member is designed for static access). Static access is especially useful for implementing the singleton design pattern, where only one instance of class exists."

Complete Story

Related Stories: