PHP
  Home arrow PHP arrow Page 2 - 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? 
Google.com  
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 - Establishing a basic class hierarchy
    ( Page 2 of 4 )

    Since the main goal of this series is to illustrate how inheritance can be used to build an object-oriented web site, I'm going to define a base web page class, which will be tasked with setting up the blueprints for all the child objects derived from it.

    This being said, the corresponding signature for this brand new web page class is listed below:

    // define abstract 'WebPage' class
    abstract class WebPage{
       private $html;
       private $title;
       private $mainLinks;
       private $content;
       abstract public function __construct($title,$content);
       abstract public function buildMetaData();
       abstract public function buildStyles();
       abstract public function buildHeader();
       abstract public function buildLinks();
       abstract public function buildBody();
       abstract public function buildFooter();
    }

    As shown above, the "WebPage" class has been defined as abstract, since it only establishes a generic model of how to build a simple web page. This is clearly reflected by the abstract methods declared by the class in question.

    Besides, it's worthwhile to mention here that the previous base class presents a very straightforward structure for outlining the generic characteristics of a basic web document. Nonetheless, as you'll see in a few moments, all the child classes created from this parent will implement concretely all of its methods, in this way allowing the creation of a specific web page.

    So far, so good right? At this point you learned how to build a base web page class, which simply behaves as an interface for generating specific web documents. Thus, considering the fact that you may want to see how a subclass derived from the previous parent "WebPage" can be provided with the required business logic to create a concrete web document, in the section to come I'm going to explain this procedure in detail.

    So, want to learn how this brand new child class will be defined? Okay, click on the link below and keep reading.



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

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek