遇到错误无法加载请求的类:Sistema [No AutoLoad] CodeIgniter

时间:2015-11-12 13:30:28

标签: php codeigniter content-management-system

所以,我正在按照教程和修改代码,有一点我无法修复它,无法理解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

有人知道如何解决它?

1 个答案:

答案 0 :(得分:0)

将您的库重命名为Sistema并将其放入application / libraries文件夹

class Sistema
{
    protected $ci;
    public $theme = array();

    public function __construct(){
        $this->ci =& get_instance();
        $this->ci->load->helper('functions');
    }
}

您可以找到加载库here

的文档