PHP
  Home arrow PHP arrow Page 5 - Working with Directory Iterators and P...
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

Working with Directory Iterators and Proxy Classes with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-01-09

    Table of Contents:
  • Working with Directory Iterators and Proxy Classes with PHP 5
  • Defining the initial structure of a proxy directory class
  • Improving the functionality of the proxy class
  • Completing the proxy pattern
  • Developing a final example

  • 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


    Working with Directory Iterators and Proxy Classes with PHP 5 - Developing a final example


    (Page 5 of 5 )

    As I promised before, below I developed an illustrative example that shows how to obtain useful information about a sample "defaultPath" directory, which also contains two text files called "file1.txt" and "file2.txt" respectively. For this specific example, I listed sequentially the different values outputted when a particular method is called, so you can see more clearly how the proxy class does its business.

    Here is the example in question:

    try{ // instantiate 'ProxyDirectoryProcessor' object $pDirProc=new ProxyDirectoryProcessor(); // display path of selected directory echo $pDirProc->getPath(); /* displays the following: defaultPath */ // display size of directory entries echo $pDirProc->getSize(); /* displays the following: Size for directory entries are as following: Size for current element is :0 Size for current element is :0 Size for current element is :29 Size for current element is :29 */ // display names of directory entries echo $pDirProc->getFileNames(); /* displays the following: Name for directory entries are as following: Name of current file is : file1.txt Name of current file is : file2.txt */ // display timestamps of directory entries echo $pDirProc->getTimeStamps(); /* displays the following: Timestamps for directory entries are as following: Timestamp of current file is : 1160523911 Timestamp of current file is : 1160523922 */ // display last access timestamps of directory entries echo $pDirProc->getLastTimeStamps(); /* displays the following: Last access timestamps for directory entries are as following: Last access timestamp of current file is : 1160523911 Last access timestamp of current file is : 1160523922 */ // display inode timestamps of directory entries         echo $pDirProc->getInodeLastTimeStamps();         /* displays the following: Last inode modification timestamp for directory entries are
    as following: Last inode modification timestamp of current file is : 1160523911 Last inode modification timestamp of current file is : 1160523922 */ } catch(Exception $e){ echo $e->getMessage(); exit(); }

    After studying the above example, hopefully you'll have a better background on how the proxy pattern works. As homework, try defining more methods for the directory processor, and for the proxy class as well. Fun is already guaranteed!

    Final thoughts

    In this two-part series, I introduced the key points concerning the implementation of the proxy pattern in PHP 5. As you hopefully learned, this pattern can be used when you want to avoid an unnecessary instantiation of a particular object, something that eventually can improve the overall performance of your application.

    As usual, see you in the next PHP tutorial!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Over this final installment of the series, you'll learn how to create proxy objects,...
     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - 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
    - 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
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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