Back to index

php5  5.3.10
Functions
autoload.inc File Reference

function __autoload More...

Go to the source code of this file.

Functions

 __load_class ($classname, $dir)
 __autoload ($classname)
 Class loader for SPL example classes.

Detailed Description

function __autoload

Author:
Marcus Boerger
Date:
2003 - 2005

SPL - Standard PHP Library

Definition in file autoload.inc.


Function Documentation

__autoload ( classname)

Class loader for SPL example classes.

Author:
Marcus Boerger
Version:
1.0

Loads classes automatically from include_path as given by ini or from current directory of script or include file.

Definition at line 34 of file autoload.inc.

                                {
       $classname = strtolower($classname);
       $inc = split(':', ini_get('include_path'));
       $inc[] = '.';
       $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
       foreach($inc as $dir)
       {
              if (__load_class($classname, $dir))
              {
                     fprintf(STDERR, 'Loading class('.$classname.")\n");
                     return;
              }
       }
       fprintf(STDERR, 'Class not found ('.$classname.")\n");
}

Here is the call graph for this function:

__load_class ( classname,
dir 
)

Tries to load class $classname from directory $dir.

Definition at line 15 of file autoload.inc.

{
       $file = $dir . '/' . $classname . '.inc';
       if (file_exists($file))
       {
              require_once($file);
              return true;
       }
       return false;
}

Here is the caller graph for this function: