Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 存在,但不存在';t声明类代码点火器_Php_Function_Codeigniter_Class - Fatal编程技术网

Php 存在,但不存在';t声明类代码点火器

Php 存在,但不存在';t声明类代码点火器,php,function,codeigniter,class,Php,Function,Codeigniter,Class,我试图加载这个名为“m_cart”的模型,但它在我的控制器上不起作用。我在这里遇到一个错误“M_cart.php存在,但没有声明类M_cart” Controller Part.php 您的模型必须声明为扩展CI\U模型的类 Class M_cart extends CI_Model { function get_all_produk() { $hasil=$this->db->get('produk'); return $hasil

我试图加载这个名为“m_cart”的模型,但它在我的控制器上不起作用。我在这里遇到一个错误“M_cart.php存在,但没有声明类M_cart”

  • Controller Part.php

  • 您的模型必须声明为扩展
    CI\U模型的类

    Class M_cart extends CI_Model
    {
    
        function get_all_produk()
        {
            $hasil=$this->db->get('produk');
            return $hasil->result();
        }
    
        function some_other_model()
        {
            // some other thing
        }
    }
    
  • 如果您要声明
    class Cart
    (不要忘记扩展
    CI\u Controller
    ),则控制器名称应为
    Cart.php
    而不是
    Part.php
  • m_cart
    中的m应在文件名
    m_cart.php
    和声明中大写,并应扩展
    CI_模型
    ,例如
    类m_cart扩展CI_模型
  • 如果两者都无法工作,请确认您正在编辑与测试相同的副本

         <?php
        class Cart_model extends CI_Model{
    
            function get_all_produk(){
                $hasil=$this->db->get('produk');
                return $hasil->result();
            }    
    
    Class M_cart extends CI_Model
    {
    
        function get_all_produk()
        {
            $hasil=$this->db->get('produk');
            return $hasil->result();
        }
    
        function some_other_model()
        {
            // some other thing
        }
    }