Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Alex Williams http://www.alexwilliams.ca

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Load a PHP Class automatically upon instantiation (PHP5)

When you instantiate a class, it will try to load the file automatically.
   1  
   2  function __autoload($class_name) {
   3      require_once("classes/" . $class_name . ".php");
   4  }

Usage:
   1  $auth = new Auth;

Will automatically load the file "classes/Auth.php"
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS