我收到以下错误消息:
Warning: include_once(Zend\Db.php) [function.include-once]: failed to open stream: No such file or directory in C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 83 Warning: include_once() [function.include]: Failed opening 'Zend\Db.php' for inclusion (include_path='VPZ/') in C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 83 Warning: require_once(Zend/Exception.php) [function.require-once]: failed to open stream: No such file or directory in C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 87 Fatal error: require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='VPZ/') in C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 87
我想包括ZendXXX\Db.php
如何改变它
创建一个目录(比如'lib'),并将Zend目录放入其中.所以你的目录结构如下所示:
- application - lib |- Zend - wwwroot |- index.php
现在你应该在你的包含路径中添加lib.编辑index.php文件:
$includePath = array(); $includePath[] = '.'; $includePath[] = './../application'; $includePath[] = './../lib'; $includePath[] = get_include_path(); $includePath = implode(PATH_SEPARATOR,$includePath); set_include_path($includePath);
现在,您的包含路径中包含了lib.你可以包括所有Zend组件,如下所示:
include 'Zend/Loader.php'; require_once 'Zend/Db.php';
最好的方法是首先包含Zend_Loader,然后使用它来加载类.做这个:
require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Db');
您也可以注册自动加载课程.只需在以下所有内容之后将此行添加到您的代码中:
Zend_Loader::registerAutoLoad('Zend_Loader',true);
现在您不需要包含文件来调用类.只是实现你的课程:
$ session = new Zend_Session_Namespace('user');
没有必要包含'Zend/Session/Namespace.php'.