PHP
  Home arrow PHP arrow User-defined Interfaces in PHP 5: Intr...
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: Introduction to Core Concepts
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2005-12-19

    Table of Contents:
  • User-defined Interfaces in PHP 5: Introduction to Core Concepts
  • What are interfaces? Defining core concepts
  • The practical side: defining the “DeSerializer interface and “PostSaver” class
  • Making the Round Trip: defining the “MySQLCache” class
  • A functional example: using the “MySQLCache” and “PostSaver” classes

  • 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: Introduction to Core Concepts


    (Page 1 of 5 )

    PHP5 takes users increasingly in the direction of object-oriented programming. The Standard PHP Library (SPL) is a new item that helps developers both with the creation of OOP applications and the maintenance of standardization. The SPL enables developers to work with user-defined interfaces. In this article, the first of a series, Alejandro Gervasio uses examples to introduce you to working with these interfaces, which can keep you from having to reinvent the wheel with each new project.

    With the release of PHP5, a strong effort has been made to improve the existing Object Model available in previous versions of PHP. Taking PHP into the context of object-oriented programming was certainly a controversial topic, and very often the subject of many heated discussions. One recurring theme was the absence of relevant OOP features, available from long mature object-oriented languages such as Java or C++.

    In response to that, PHP5 brought in a wealth of brand new features, designed specifically to provide programmers with the capacity to develop more robust OOP applications, while maintaining a strong sense of standardization, particularly with the introduction of the Standard PHP Library (SPL) within the PHP5 core distribution.

    If you’ve already experienced the capabilities of PHP5, then you’re probably pretty familiar with the use of several PHP built-in interfaces such as “Iterator”, “IteratorAggregate” or “ArrayAccess” (to name the most popular ones) and some useful proprietary classes, like “ArrayIterator” or “ArrayObject”, aimed at solving standard problems.

    Aside from this impressive set of built-in features included within the SPL, PHP5 offers the possibility of working with user-defined interfaces, allowing a class to use any number of interfaces within program execution, by explicitly declaring them when the pertinent class is defined.

    In this tutorial, I’ll introduce the use of user-defined interfaces in PHP5, covering the basics of its theory along with the implementation of different examples, aimed specifically at demonstrating its functionality in real applications.

    Before we get started, a few items with be required. You should have at least a basic familiarity with the PHP5 syntax, along with an intermediate knowledge of concepts related to object-oriented programming. Therefore, having defined the objectives of the article, let’s move on to learning about user-defined interfaces in PHP5.

    More PHP Articles
    More By Alejandro Gervasio


       · This first chapter of the series explains the key points of Interfaces in PHP 5, and...
       · I am in the second year of Computer Science, and yesterday I finished reading...
       · I'm glad to know that my article has been helpful to you, in order to understand the...
       · Fatal error: Access type for interface method DeSerializer::getSerializedData() must...
       · Thanks for the comments on my PHP interfaces article. I don't know how you're...
     

       

    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 2 hosted by Hostway
    Stay green...Green IT