PHP
  Home arrow PHP arrow Building Object-Oriented Web Pages wit...
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 
Actuate Whitepapers 
Moblin 
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: 4 stars4 stars4 stars4 stars4 stars / 8
    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:
      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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    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


       · In this first tutorial of the series, the concept od inheritance is applied, in...
       · Why would you not put sub-link functionality in the base class???If you know...
       · Thank you for posting your opinions with regard to my PHP article, and sorry to read...
     

       

    PHP ARTICLES

    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...




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