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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap

Dev Shed Tutorial Topics: