Home  >  Article  >  Backend Development  >  Analyze how zend Framework automatically loads classes_PHP tutorial

Analyze how zend Framework automatically loads classes_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:02:06963browse

1. Automatic loading of classes in modules

Copy code The code is as follows:

$loader = new Zend_Application_Module_Autoloader(array( //Module content automatic loading class
'namespace' => 'Blog',//The namespace definition means the beginning of the method is Blog_
'basePath' => APPLICATION_PATH . '/modules /blog',//Module location
));

2. Automatic loading
Copy code The code is as follows:

require_once 'Zend/Loader/Autoloader.php';
$loader =Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace( 'Application_');
//Please pay attention to whether the loaded directory address has been loaded

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327949.htmlTechArticle1. The copy code for automatic loading of classes in the module is as follows: $loader = new Zend_Application_Module_Autoloader(array( // Module content automatically loads class 'namespace' = 'Blog', // Namespace definition...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn