1.3. Zend::loadClass()

Zend::loadClass($class, $dirs) loads a PHP file and then checks for the existance of the class.

<?php

Zend::loadClass('Container_Tree', array('/home/production/mylib', (/home/production/myapp')));

?>

After converting $class to a path hierarchy by substituting directory separators for any underscores, the resulting hierarchy is appended to each path in $dirs If $dirs is null, then the result will contain only the single hierarchy. For example, Container_Tree becomes Container/Tree.php. If /home/production/mylib/Container/Tree.php exists, then it will be included. If not, then /home/production/myapp/Container/Tree.php will be included, if it exists. Otherwise, PHP's include path will be searched for Container/Tree.php.

If $dirs is a string or an array, the directories are searched in the order supplied, and the first matching file will be included. If the file does not exist in the calculated $dirs, then PHP's include_path will be used by the include statement (i.e. include 'Tree.php').

If the file is not found or the class does not exist after the load, a Zend_Exception is thrown. Zend::loadFile() is used for loading, so the class name may only contain alphanumeric characters and the hyphen ('-'), underscore ('_'), and period ('.').