PHP
  Home arrow PHP arrow User-defined interfaces in PHP 5: Impl...
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

User-defined interfaces in PHP 5: Implementing (X)HTML Widgets
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2005-12-26

    Table of Contents:
  • User-defined interfaces in PHP 5: Implementing (X)HTML Widgets
  • Generic (X)HTML generation: defining the "HTMLRenderer" interface
  • Working with interface implementers: defining (X)HTML widget classes
  • Object-based (X)HTML rendering: more (X)HTML widgets to define
  • Completing the list of (X)HTML widgets: defining classes for rendering headers and forms

  • 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


    User-defined interfaces in PHP 5: Implementing (X)HTML Widgets


    (Page 1 of 5 )

    In this second part of the series, you will learn the basics of object-oriented web page generation through the use of (X)HTML widgets. You will also see how objects implement the “HTMLRenderer” interface to explicitly define its functionality by using the “toHTML()” method.

    Welcome to the second part of the series "User-defined interfaces in PHP5." By way of returning to the first article, I explained the basics for using interfaces within a PHP5 application. I also provided you with a pair of sample classes that implemented the same "DeSerializer" interface. As you surely remember, the interface's abstract methods were explicitly defined to work with byte-stream representations of data.

    In addition to implementing a functional example for utilizing the sample classes, some key concepts related to interfaces were introduced as part of the tutorial. By combining the underlying theory together with the practical usage, hopefully you now understand the way in which interfaces are implemented in PHP5.

    Over this second part of the series, I'll go further into the implementation of interfaces, by introducing several classes aimed specifically at generating (X)HTML "widgets" as a method of generating web pages from an object-oriented point of view. The use of independent programming structures for creating (X)HTML page objects is yet another method for building web pages focused primarily on the handled data rather than on the overall page layout used in template-based systems.

    Generally, presentational widgets -- including (X)HTML widgets -- offer a greater level of flexibility for larger web programs because they allow you to define application layers in a very clear way. On top of the application, the data layer is defined (comprised of backend databases), then probably a data access layer is added (usually implemented through a persistent layer) between the databases and the core logic layer. Finally the presentational layer is set up, which receives the data and uses the widgets to generate the user interface.

    The drawback to the "widget" approach resides mainly in the performance cost of creating many objects for rendering a web document, even if they only exist until the page has finished displaying.

    However, and leaving out the pros and cons of presentational widgets, I'll explain a more complex usage of interfaces by associating several (X)HTML widget classes to a couple of the MySQL processing classes, in this way demonstrating how objects of different types can be "hooked up" to each other through a common shared interface, in a real application.

    Having defined the goals of this second tutorial, let's get started.

    More PHP Articles
    More By Alejandro Gervasio


       · The second article illustrates the use of interfaces by creating a set of (X)HTML...
     

       

    PHP ARTICLES

    - 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
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





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