遇到错误无法加载请求的类:Sistema [No AutoLoad] CodeIgniter(An Error Was Encountered Unable to load the requested class: Sistema [No AutoLoad] CodeIgniter)
所以,我正在关注一个教程并修改代码,有一点我无法修复它,无法理解为什么CI没有加载类。 这是功能:
function set_theme($propriedade, $valor, $replace = TRUE){ $ci =& get_instance(); $ci->load->library('sistema'); if($replace){ $ci->sistema->theme[$propriedade] = $valor; }else{ if (!isset($ci->sistema->theme[$propriedade])) { $ci->sistema->theme[$propriedade] = ""; } $ci->sistema->theme[$propriedade] .= $valor; } } // <-- end set_theme -->而sistema.php类是:
<?php class MY_Sistema{ protected $ci; public $theme = array(); public function __construct(){ $this->ci =& get_instance(); $this->ci->load->helper('functions'); } }当我在控制器上调用set_theme()时,它只会给出错误:
An Error Was Encountered Unable to load the requested class: Sistema有人知道如何解决它?
So, I was following a tutorial and modifying the code, and there is a point that I can't fix it, a can't see why CI isn't loading the class. This is the function:
function set_theme($propriedade, $valor, $replace = TRUE){ $ci =& get_instance(); $ci->load->library('sistema'); if($replace){ $ci->sistema->theme[$propriedade] = $valor; }else{ if (!isset($ci->sistema->theme[$propriedade])) { $ci->sistema->theme[$propriedade] = ""; } $ci->sistema->theme[$propriedade] .= $valor; } } // <-- end set_theme -->And the class sistema.php is:
<?php class MY_Sistema{ protected $ci; public $theme = array(); public function __construct(){ $this->ci =& get_instance(); $this->ci->load->helper('functions'); } }And when I call set_theme() it on the controller, it just give the error:
An Error Was Encountered Unable to load the requested class: SistemaSomeone got an Idea of how to fix it?
最满意答案
将库重命名为Sistema并将其放入应用程序/库文件夹中
class Sistema { protected $ci; public $theme = array(); public function __construct(){ $this->ci =& get_instance(); $this->ci->load->helper('functions'); } }你可以在这里找到加载库的文档
Rename your library to Sistema and place it into the application/libraries folder
class Sistema { protected $ci; public $theme = array(); public function __construct(){ $this->ci =& get_instance(); $this->ci->load->helper('functions'); } }You can find the documentation for Loading a library here
更多推荐
发布评论