PHP
  Home arrow PHP arrow Enforcing Object Types in PHP: Using t...
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

Enforcing Object Types in PHP: Using the Type Hinting Feature in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-03-01

    Table of Contents:
  • Enforcing Object Types in PHP: Using the Type Hinting Feature in PHP 5
  • The “Type Hinting” feature of PHP 5: taking an in-depth look
  • A practical example: using “Type Hinting” within a web page generator class
  • Putting “Type Hinting” to work: building object-based web documents

  • 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


    Enforcing Object Types in PHP: Using the Type Hinting Feature in PHP 5


    (Page 1 of 4 )

    Here we are again. Welcome to the last tutorial of the series “Enforcing object types in PHP.” As this article’s title suggests, this series introduces the basics of object type enforcement in PHP, covering some of the most common methods for checking types of objects in both PHP 4 and PHP 5 respectively.

    Introduction

    As you’ll hopefully recall, in the previous article I explained the key points of using the “instanceof” operator available in PHP 5, in order to check the type of objects that eventually could be passed as input arguments to other PHP classes across the same Web application.

    True to form, this operator is very useful in cases where filtering objects is a must, and of course when the flow of an application must be moved to different code blocks, in accordance with the type of object aggregated to a particular class. Additionally, you can use the “instanceof” operator for checking whether certain objects are implementers of a specific interface too. As you can see, possibilities for utilizing this operator in PHP 5 applications are certainly numerous.

    Now, returning to the subject of this last tutorial, I’ll introduce another method for enforcing object types in PHP 5: the “Type Hinting” feature. It can also be used in conjunction with the “instanceof” operator that you learned about before, in order to develop PHP applications that implement thorough routines for filtering unwanted objects. Generally speaking, when you finish reading this article, you should be armed with a few more methods for forcing object types in PHP, in this way expanding your overall knowledge of object-oriented programming. 

    With the formalities out of the way, let’s get started.

    More PHP Articles
    More By Alejandro Gervasio


       · If you read the previous articles of this series, probably you'll find this one...
       · It's unrelated to the main focus of the story, sorry, but why do...
       · Hello,The reason for coding that statement is simple: since the loop that...
     

       

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