autoload.inc File Reference

function __autoload More...

Go to the source code of this file.

Functions

 __autoload ($classname)
 __load_class ($classname, $dir)


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.

References $dir, and __load_class().

00034                                 {
00035     $classname = strtolower($classname);
00036     $inc = split(':', ini_get('include_path'));
00037     $inc[] = '.';
00038     $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
00039     foreach($inc as $dir)
00040     {
00041         if (__load_class($classname, $dir))
00042         {
00043             fprintf(STDERR, 'Loading class('.$classname.")\n");
00044             return;
00045         }
00046     }
00047     fprintf(STDERR, 'Class not found ('.$classname.")\n");
00048 }

Here is the call graph for this function:

__load_class

__load_class ( classname,
dir 
)

For internal use only.

Tries to load class $classname from directory $dir.

Definition at line 15 of file autoload.inc.

References $dir.

Referenced by __autoload().

00016 {
00017     $file = $dir . '/' . $classname . '.inc';
00018     if (file_exists($file))
00019     {
00020         require_once($file);
00021         return true;
00022     }
00023     return false;
00024 }


Generated on Thu Apr 26 01:04:48 2007 for SPL-StandardPHPLibrary by  doxygen 1.5.2