PHP5 Autoload classes

This is really handy for medium to large size projects. You don’t have to remember to put a set of require_once functions in every file.  I usually put this in a config file that’s loaded early and on every page.

function __autoload($class_name) {
   require_once $class_name . ‘.php’;

$obj  = new MyClass1();
$obj2 = new MyClass2();

See for more information.

Comments are closed.