【发布时间】:2017-08-02 00:38:43
【问题描述】:
下面列出了我当前的控制器和库...
>application/
- config/
- controllers/
- ...
- models/
- modules/
- module1/
- controllers/
- Test_cont.php
- models/
- views/
- libraries
- Test_lib.php
- third_party/
- views/
- ...(other files & folders)
'modules/module1/controllers/Test_cont.php'是:
class Test_cont extends MY_Controller
{
function __construct(){
parent::__construct();
}
function index(){
$this->load->library('Test_lib');
$this->Test_lib->doSomething();
}
}
'modules/module1/libraries/Test_lib.php'文件是:
class Test_lib
{
function __construct(){
echo 'library loaded <br>';
}
function doSomething(){
echo 'it works!';
}
}
当我访问 URL 'http://localhost/codeigniter-3.1.3/module1/test_cont' 它说:
---------------------------------------------------
| An Error Was Encountered |
---------------------------------------------------
| Unable to load the requested class: Test |
---------------------------------------------------
我希望我能让你理解我的问题,如何解决这个问题?... (提前致谢)
【问题讨论】:
-
尝试像
$this->load->library('module1/test_lib');这样加载库并使用小写语法。 -
@smokehill 如果你想从另一个模块访问库,你只需要写“模块/库”
-
@Amin 你的问题解决了吗?
-
是的,它的工作方式如下... $this->load->library('Test_lib');
-
嗨@Amin - 如果您接受对您有帮助的答案或添加您自己的答案来解决问题,如果缺少正确答案,那就太好了:)
标签: php codeigniter codeigniter-3 hmvc codeigniter-hmvc