PHP
  Home arrow PHP arrow The Autoload Magic Function in PHP 5
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

The Autoload Magic Function in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2009-06-22


    Table of Contents:
  • The Autoload Magic Function in PHP 5
  • Review: the destruct method
  • Loading classes automatically with the autoload magic function
  • Loading classes in the background with the autoload function

  • 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


    The Autoload Magic Function in PHP 5
    ( Page 1 of 4 )

    Among the improvements and new features that were introduced to PHP 5, there’s a set of special functions, popularly known as magic functions. These allow you to perform all sorts of smart tasks, ranging from overloading properties and methods in classes, to using destructors and triggering automatically predefined processes when serializing and unserializing objects. This is the conclusion to a seven-part series that shows you how to use the magic functions in PHP 5.

    So, if you’re a PHP developer who wants to learn how to put these magic functions to work for you in a truly effortless way, or wishes to fill some gaps in your knowledge regarding their correct implementation and usage, then this group of tutorials might be the guide that you’re looking for.

    And now that you know what to expect from this series of articles, it’s to review the topics that were discussed in the last one. In that particular tutorial I discussed the implementation of a destructor method within a simple class, via the pertinent “__destruct()” function.

    In that particular situation, this function was provided with the capability to save an instance of the originating class to a session variable before being destroyed by the PHP interpreter. In doing so, I hopefully demonstrated how to create basic persistent objects by using only a simple destructor. Not too bad at all, right?

    However, PHP 5 offers yet another magic method that can be extremely useful for loading classes automatically, without having to use explicitly any “include()/include_once()” or “require()/require_once()” function. As the article’s title suggests, I’m talking specifically about the “__autoload()” function, which deserves a deeper analysis.

    Therefore, this last chapter of the series will be focused exclusively on exploring the potential of this function for including classes in a transparent way. So, jump ahead and start learning more about it!



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

       

    PHP ARTICLES

    - 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...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





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