PHP
  Home arrow PHP arrow User-defined interfaces in PHP 5: Implementing (X)HTML Widgets
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

User-defined interfaces in PHP 5: Implementing (X)HTML Widgets
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      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


    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
     

       

    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