PHP
  Home arrow PHP arrow Inheritance and Polymorphism in PHP: B...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Inheritance and Polymorphism in PHP: Building a Form Generator - Part I
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 34
    2005-04-05

    Table of Contents:
  • Inheritance and Polymorphism in PHP: Building a Form Generator - Part I
  • A Quick Look at Basic OOP Concepts
  • The Base Class of the Form Generator
  • Applying Inheritance: Creating Subclasses

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Inheritance and Polymorphism in PHP: Building a Form Generator - Part I


    (Page 1 of 4 )

    Object Oriented Programming (OOP) is a powerful technology for designing Web applications. This article is the first in a three part series that will explain two of the bases of OOP, Inheritance and Polymorphism, and apply these principles to building an extensible form generator.

    Introduction

    If you ever tasted the power of Object Oriented Programming (OOP) in PHP, then you probably know that it's an extremely useful way to manage medium and large projects, where code reusability, extendibility and maintainability are key factors that make developing Web applications a relatively painless experience. Without a doubt, with the release of PHP 5, these advantages have been greatly enhanced due to the highly improved object model (to name a few new excellent features), which turns the present and hopefully, the future of OOP in PHP bright and extremely promising.

    However, when we're talking about PHP 4, often there are complaints about the lack of support when it comes to applying OOP. Many reasons form the foundation for this criticism, such as an absence of access modifiers, lack of abstract classes and even no support for multiple inheritance. While this is all true, in fact nothing stops developers from applying OOP theory in real applications. All that you need is the knowledge to implement OOP in a fairly decent way.

    Although opinions may differ (and certainly it's out of the scope of this article), I strongly believe that the limitations present in PHP 4 are easily overcome, giving programmers a valid reason to keep using OOP in PHP programming.

    Since we pushed some misconceptions out of the way, it's time to focus our attention on two primary bases of OOP: Inheritance and Polymorphism. In the rest of this article, we'll introduce these concepts as they are applied in PHP, with a rather practical approach, in order to find their place in a real application: building an extensible form generator.

    For experienced programmers, this surely will look like a rather boring topic. However, for beginning and intermediate PHP users, this might be a straightforward way to gracefully enter the OOP arena, without feeling completely overwhelmed. Keep reading; you'll find it's quite worthwhile. 

    More PHP Articles
    More By Alejandro Gervasio


       · Eve the subject has been treated many times on books and articles, the article is...
       · That's a really awkward place to stop Part I. If you didn't have time to finish the...
       · Uh, please pardon the tone of my post above. You made it quite clear in the summary...
       · Your apologies are accepted. No problem about that. Even my schedule is pretty...
       · In trying to understand all that was said I am a little confused about some things...
       · Well I have some expirience programing php and I would like to suggest that in many...
       · Sorry, I forgot to include a sample of the “alternative syntax” I was referring to....
       · Yes, you're correct. Sometimes when you have many parameters to be passed to the...
       · Hi friend,I guess you're refering to the ternary operator. Well, it's an easy way...
       · Hi there,I guess you're talking about the ternary operator. It's often used to...
       · The usage of the :: syntax is the following. You can call a function defined in an...
       · Thanx for the great tutorial, I've used in some way OO programing in my scripts but...
       · Hi dear friend,I'm glad you found this tutorial useful for your growing...
       · Is there any reason why u decided to use PHP4 and its object syntax? Wouldn't it be...
       · Despite the fact that PHP5 offers much better support for OOP, their usage is still...
       · Thanks for sharing us your very nice article! jen
       · Thank you for your compliments about the article. Your comments are deeply...
     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway