PHP
  Home arrow PHP arrow Using the _autoload() Magic Function to Build Loader Appps 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? 
PHP

Using the _autoload() Magic Function to Build Loader Appps in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-06-24


    Table of Contents:
  • Using the _autoload() Magic Function to Build Loader Appps in PHP
  • Review: building a file loader class the old way
  • Loading files with the autoload PHP magic function
  • Implementing an enhanced exception mechanism

  • 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


    Using the _autoload() Magic Function to Build Loader Appps in PHP
    ( Page 1 of 4 )

    Welcome to the sixth part of an eight-part series that shows you how to build file loader applications in PHP. In this part I will discuss how to build a helpful file loading application by taking advantage of the nifty “__autoload()” magic function.

    There are a number of tasks that PHP developers must tackle on a regular basis when building well-structured web applications. One of these is creating scripts that load a certain number of resources and dependencies required for those applications to work as expected.

    While developing these file loading scripts can be as simple as using PHP includes for each requested file, there are specific situations when it’s necessary to create more complex loader programs that incorporate some additional features, such as automatic inclusion of dependencies, and recursive search of them across a given file system path as well. 

    Developing an application like the one described above with PHP 5 isn’t as hard as it may seem at first glance, especially when taking advantage of the functionality provided by the Standard PHP Library (SPL) in conjunction with the “__autoload()” magic function. 

    In the previous installments of this series I went through the process of creating a file loader class. This class was not only capable of seeking and including a targeted file by recursively traversing the directories and subdirectories of a supplied path, but it had the ability to perform this task without having to spawn any instances of the aforementioned class.  

    How was this achieved? Well, by simply calling the class's main loader method statically and nothing else. It was that easy, really. 

    But, as I mentioned a few lines before, it’s also feasible (and desirable) to construct file loading applications by combining certain built-in features of PHP 5, such as its “__autoload()” magic function, among others. Therefore, in this sixth chapter of the series I’m going to explain how to build a brand new file loader mechanism that will rely on this PHP 5 function. 

    Now, it’s time to leave all of the preliminaries behind us and start learning how to create a file loading system around the handy “__autoload()” function. Let’s begin right away!



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

       

    PHP ARTICLES

    - 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...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT