Book Image

Object-Oriented Programming with PHP5

By : Hasin Hayder
Book Image

Object-Oriented Programming with PHP5

By: Hasin Hayder

Overview of this book

<p>Some basic objected-oriented features were added to PHP3; with PHP5 full support for object-oriented programming was added to PHP. Object-oriented programming was basically introduced to ease the development process as well as reduce the time of development by reducing the amount of code needed. OOP can greatly improve the performance of a properly planned and designed program.</p> <p>This book covers all the general concepts of OOP then shows you how to make use of OOP in PHP5, with the aid of an ample number of examples.</p>
Table of Contents (15 chapters)
Object-Oriented Programming with PHP5
Credits
About the Author
About the Reviewers
Introduction
Index

Interface


Interface is an empty class which contains only the declaration of methods. So any class which implements this interface must contain the declared functions in it. So, interface is nothing but a strict ruling, which helps to extend any class and strictly implement all methods defined in interface. A class can use any interface by using the implements keyword. Please note that in interface you can only declare methods, but you cannot write their body. That means the body of all methods must remain blank.

So why is an interface necessary, you might ask? One of the reasons is it implies strict rules while creating a class. For example, we know that we need to create some driver classes in our application, which can handle DB operations. For MySQL, there will be one class, for PostgreSQL there will be another, For SQLite, another one and so forth. Now your developer team has three developers, who will separately create these three classes.

Now how will it be if each of them implements...