PHP
  Home arrow PHP arrow Abstract Classes in PHP: Setting Up a ...
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Abstract Classes in PHP: Setting Up a Concrete Example
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2006-02-01

    Table of Contents:
  • Abstract Classes in PHP: Setting Up a Concrete Example
  • Setting up a concrete example: Defining the hierarchy of classes
  • Deriving subclasses from the parent abstract class: defining the “resultProcessor” class
  • More subclasses ahead: defining the “fileProcessor” class
  • Assembling the pieces: putting the classes to work together

  • 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


    Abstract Classes in PHP: Setting Up a Concrete Example


    (Page 1 of 5 )

    Welcome to part two of the series “Abstract classes in PHP.” In three tutorials, this series introduces the key concepts of abstract classes in PHP 4-PHP 5, and explores their application and use in different object-oriented development environments. Whether you’re an experienced PHP developer wanting to fill in some gaps related to abstract classes, or only a beginner starting to taste the power of object-based programming in PHP, hopefully you’ll find this series enjoyable and instructive.

    Introduction

    As you’ll probably recall, in the first article I thoroughly explained the key points for implementing abstract classes in PHP 4, and demonstrated different methods of using them within a PHP application. Since PHP 4 doesn’t offer true support for abstract classes, that is, classes that can’t (and shouldn’t) be instantiated, I went through the development of different approaches for preventing a specific class from direct instantiation. In accordance with this situation, I illustrated a few common approaches to prevent a class from being instantiated, ranging from including a “die()” statement inside the class constructor, to developing more polished techniques, such as utilizing a combination of the “get_class()” and “is_subclass()” PHP built-in functions.

    As you know, this last method was also aimed at preventing a class from being instantiated from non child classes. This implies having a decent approach for using abstract classes, particularly in PHP 4 programming environments, where such classes aren’t natively supported.

    Now, returning to this second installment of the series, and assuming that abstract classes aren’t foreign concepts to you any longer, I’ll go one step further in the corresponding learning curve.  I will set up a couple of more helpful examples, which I hope will serve as an introduction to using PHP 4 abstract classes in some concrete situations, something definitely much closer to the needs that most PHP developers have to face on a daily basis.

    Right, having defined the objectives of this tutorial, it’s time to move on and learn how abstract classes can be put to work in some concrete situations. Let’s get started.

    More PHP Articles
    More By Alejandro Gervasio


       · After explaining how to code abstract classes in PHP 4, the second part of the...
       · Good article. I'm learning more each time you post an article. Thnak you.btw,...
       · I'm glad to know you liked the article on PHP abtract classes. Also, thank you for...
       · It looks like I really don't get it...What's the difference between using the...
       · Hello,Thank you for commenting on my article. Yes, you're correct that the...
     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





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