Home > php教程 > php手册 > body text

解析zend Framework如何自动加载类

WBOY
Release: 2016-06-13 11:44:07
Original
928 people have browsed it

1.模块中类的自动载入

复制代码 代码如下:


$loader = new Zend_Application_Module_Autoloader(array(   //模块内容自动加载类
    'namespace' => 'Blog',//命名空间定义 即方法的开头为Blog_
    'basePath'  => APPLICATION_PATH . '/modules/blog',//模块位置
));


2. 自动载入

复制代码 代码如下:


require_once 'Zend/Loader/Autoloader.php';
$loader =Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Application_');
//须注意载入的目录地址是否已经被载入


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template