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

« 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.
function __autoload($class_name) {
    require_once("classes/" . $class_name . ".php");
}

Usage:
$auth = new Auth;

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