Home arrow PHP arrow Using Different Objects in the Same Script for Polymorphs in PHP

Using Different Objects in the Same Script for Polymorphs in PHP

Welcome to the final part of a seven part series on building polymorphs in PHP. In a friendly fashion, this series gets you started constructing polymorph classes specifically in PHP 5. It shows you how to accomplish this by using first interfaces, then parent classes, and finally a proper combination of both.

TABLE OF CONTENTS:
  1. Using Different Objects in the Same Script for Polymorphs in PHP
  2. Review: creating polymorph classes using interfaces and abstract classes
  3. Rendering HTML divs and paragraphs within the same script
  4. Passing a different argument to the parseContent()method of the polymorph classes
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
January 20, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

And now that you've been introduced to the main goal of this group of tutorials, it’s time to review the topics discussed in the last one. In that article I explained how to build a couple of polymorph classes; both of them inherited structure from a simple interface and functionality from an abstract class responsible for rendering generic HTML elements.

Also, it’s necessary to recall that each of the classes constructed a specific HTML element through a common method called “render().” They also parsed its contents via another method, named“parseContent(),” which was inherited from the pertinent interface.

However, analyzing the construction of these sample classes separately would not be very helpful for understanding their polymorph nature. To solve this issue, in this final chapter of the series I’m going to develop a couple of scripts where the classes will be put to work together.

Now, it’s time to tackle the last part of this hopefully educational exercise in building polymorph classes with PHP 5. Let’s get going!



 
 
>>> 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 6 - Follow our Sitemap

Dev Shed Tutorial Topics: