Home arrow PHP arrow User-defined Interfaces in PHP 5: Turning MySQL Classes into Interface Implementers

User-defined Interfaces in PHP 5: Turning MySQL Classes into Interface Implementers

Welcome to the third part of the series “User-defined interfaces in PHP5.” In four parts, this series explains the use of interfaces in PHP5, highlighting their advantages and illustrating their implementation in real applications.

TABLE OF CONTENTS:
  1. User-defined Interfaces in PHP 5: Turning MySQL Classes into Interface Implementers
  2. Working with different interface implementers: defining the “MySQL” class
  3. Working with result sets: implementing the “HTMLRenderer” on result-type objects
  4. Describing the logic
By: Alejandro Gervasio
Rating: starstarstarstarstar / 10
January 02, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Having developed a large set of (X)HTML widget classes that implement an “HTMLRenderer” interface, the previous article demonstrated the use of this interface through the specific definition of its abstract “toHTML()” method. In short, I’ve provided you with a technique for grouping objects of the same family type through a common interface.

However, this fact itself does not give us a direct advantage in developing an application, because this functionality can be obtained by defining an abstract parent class, and then deriving some subclasses that either override or overload existing methods within the specific context of child classes.

Fortunately, the existence of interfaces allows grouping objects of different family types, so if you’re working with objects that don’t belong to the same type, using a common interface to implement a specific functionality is probably the right way to go.

Returning to this part of the series, I’ll demonstrate how useful interfaces can be, by implementing the “HTMLRenderer” interface on a couple of MySQL processing classes that have nothing in common with the (X)HTML widgets explained in the previous tutorial. In this way, by the end of this article you’ll have a decent background for working with interfaces as well as a clear idea about its concrete implementation in PHP applications.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: