Home arrow PHP arrow User-defined Interfaces in PHP 5: Introduction to Core Concepts

User-defined Interfaces in PHP 5: Introduction to Core Concepts

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.

TABLE OF CONTENTS:
  1. User-defined Interfaces in PHP 5: Introduction to Core Concepts
  2. What are interfaces? Defining core concepts
  3. The practical side: defining the “DeSerializer interface and “PostSaver” class
  4. Making the Round Trip: defining the “MySQLCache” class
  5. A functional example: using the “MySQLCache” and “PostSaver” classes
By: Alejandro Gervasio
Rating: starstarstarstarstar / 13
December 19, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: