PHP
  Home arrow PHP arrow Page 3 - Developing a Recursive Loading Class for Loader Applications in PHP
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

Developing a Recursive Loading Class for Loader Applications in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-06-18


    Table of Contents:
  • Developing a Recursive Loading Class for Loader Applications in PHP
  • Review: building a basic file loading class with PHP 5
  • Defining a class with recursive file searching capabilities
  • Defining the recursive load() method

  • 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


    Developing a Recursive Loading Class for Loader Applications in PHP - Defining a class with recursive file searching capabilities
    ( Page 3 of 4 )

    As I stated in the previous segment, it’s possible to build a file loading class that has the ability to look for a targeted file recursively. To create a class with this capability, first I’m going to define its basic structure along with a few setter and getter methods, which will be responsible for setting and getting the file for which to search, and for performing the same tasks with the starting file path. 

    If this brief description sounds a bit confusing to you, the following code sample should help to dissipate your doubts. Take a look at it:

     

    // define a recursive loader class

    class Loader

    {

    private $file = '';

    private $path = '';

    // constructor (not implemented)

    public function __construct(){}

     

    // set file to load

    public function set_file($file)

    {

    $this->file = $file;

    }

     

    // get file to load

    public function get_file()

    {

    return $this->file;

    }

     

    // set path to load file

    public function set_path($path)

    {

    $this->path = $path;

    }

     

    // get path to load file

    public function get_path()

    {

    return $this->path;

    }

    }

     

    As you can see, the above “Loader()” class has some simple methods, apart from the constructor, for setting and getting the file that needs to be included, and for establishing and retrieving the path from which to start searching the file. 

    These setters and getters are very easy to understand, so I’m not going to spend more time discussing how they work. But wait a minute! Didn’t I say at the beginning of this section that my purpose here was building a file loader class that is capable of including a specified file through a recursive search? Yes, I did. 

    But this functionality needs to be implemented by means of a separate method, which not surprisingly will be called “load().” 

    Therefore, to see how this whole new method will be properly defined, read the next section.



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek