Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Function Reference

__autoload ( class )

Description
/*
* Helix class autoloader.
*
* This function allows classes to be automatically loaded the first
* time they are used. This eliminates the need to include class
* files in the code.
*
* @param string $class The class name of the class being used
* @return null
*/
 
Parameters
requiredclass
 
Code
012  function __autoload($class)
013  {
014      global $classes,$ndos,$libs;
015      if (array_key_exists($class,$ndos))
016      {
017          require_once($ndos[$class]);
018      }
019      else
020      {
021          $lib = preg_match('/(.+)_(db|ext|cus)$/i',$class,$matches) ? $libs[$matches[2]] : "final";
022          $prefix = $lib=="final" ? $classes[$class] : $classes[$matches[1]];
023          $classpath = file_exists(SITE . "lib/$lib/$class.php") ? SITE . "lib/$lib/$class.php" : MODULES . "$prefix/lib/$lib/$class.php";
024          if (file_exists($classpath))
025          {
026              require_once($classpath);
027          }
028          else
029          {
030              trigger_error("__autoload() could not load the class '$class' from '$classpath'",E_USER_WARNING);
031          }
032      }
033  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads