Analyze how zend Framework automatically loads classes_PHP tutorial

WBOY
Release: 2016-07-21 15:02:06
Original
898 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!