PHP
  Home arrow PHP arrow Building Object-Oriented Web Pages with Inheritance in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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

Building Object-Oriented Web Pages with Inheritance in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2007-07-16


    Table of Contents:
  • Building Object-Oriented Web Pages with Inheritance in PHP 5
  • Establishing a basic class hierarchy
  • Using inheritance to derive a web page generator class
  • Building another web page for a fictional web site

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Building Object-Oriented Web Pages with Inheritance in PHP 5
    ( Page 1 of 4 )

    You have probably used the principles of inheritance in any number of your object-oriented programming projects. Traditionally this means working with parent and child classes during the creation of a PHP application. In this two-part series, you'll learn a simple way to use inheritance while creating object-oriented web pages.

    Introduction

    As the clever PHP developer that you surely are, it's quite probable that you've already used the object-oriented paradigm to develop one or more web applications. This implies that defining a few classes along with their methods and properties should be a pretty familiar procedure to you. Definitely, it must be admitted that building object-based applications with a friendly scripting language like PHP is not only a truly educational experience, since it requires at least a basic knowledge of software engineering, but fun as well. 

    As you possibly know, after a decent time working with this approachable -- yet mature -- web development language, it's possible to create scripts that implement a certain level of complexity, particularly when it comes to defining different relationships between several objects. And now that I mentioned the term "relationship," I'm pretty sure that you'll be familiar with the two main pillars of this huge area of object-oriented programming. I mean aggregation and composition.

    However, while learning to aggregate and compose classes with PHP (or any other programming language, naturally) can be a significant step toward mastering the fundamentals of software development, it's fair to say that these two proven models of object interaction would be rather pointless if inheritance is deliberately left out of the learning process.

    Perhaps, at the moment of reading the previous sentence you feel inclined to congratulate yourself, since you have already worked with parent and child classes here and there during the creation of a given PHP application. But one question is in order here: can inheritance be used in some way that is simpler than the traditional one, even with the purpose of doing something as trivial as building dynamic, object-oriented web pages?

    To your satisfaction (and mine, of course) the answer to the above question is a resounding yes! Actually, by using the basic principles of inheritance, it's feasible to create entire, consistent-looking web sites, with only a little effort and an intermediate background in object-oriented programming.

    So, now that I have introduced this instructive subject, in the two articles in this series I'm going to show you how to build a sample object-based web site from its bare bones structure, by using the encapsulated logic of some parent and child PHP 5 classes. In this way I'll demonstrate how inheritance can be used to tackle a concrete project, such as constructing dynamic web pages.

    All right, it's time to move forward and start learning how to utilize a simple classes hierarchy to create an expandable web site. Let's begin now!



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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT