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

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

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.

  1. Inheritance and Polymorphism in PHP: Building a Form Generator - Part I
  2. A Quick Look at Basic OOP Concepts
  3. The Base Class of the Form Generator
  4. Applying Inheritance: Creating Subclasses
By: Alejandro Gervasio
Rating: starstarstarstarstar / 50
April 05, 2005

print this article




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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: