Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 致命错误:调用未定义的方法CI_Model::User_Model()_Php_Codeigniter_Class - Fatal编程技术网

Php 致命错误:调用未定义的方法CI_Model::User_Model()

Php 致命错误:调用未定义的方法CI_Model::User_Model(),php,codeigniter,class,Php,Codeigniter,Class,有人知道我如何摆脱这个错误吗:“致命错误:调用未定义的方法CI_Model::User_Model()” 这是我的user.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class User extends CI_Controller{ function user_model(){ parent::User_model();

有人知道我如何摆脱这个错误吗:“致命错误:调用未定义的方法CI_Model::User_Model()”

这是我的user.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
    class User extends CI_Controller{    
        function user_model(){
            parent::User_model();
            $this->load->model('user_model','',TRUE);
        }
    public function index(){
        $this->login();
    }   
    function login(){
    //xss_clean doesn't work...
        $this->form_validation->set_rules('username', 'Username',                                  
        'required|trim|max_length[50]');
        $this->form_validation->set_rules('password', 'Password',     
        'required|trim|max_length[150]');       
        if ($this->form_validation->run() == FALSE){
            $this->load->view('view_login');
        }
        else{   
        }
    }
}
?>

以下是一些最明显的问题。我强烈要求你仔细检查一切


请参阅中的示例以构建模型

<?php

class User_model extends CI_Model {
    public function __construct()
    {
        // Call the CI_Model constructor
        parent::__construct();
    }
    function check_login($username, $password)
    { ....

它都应该用小写字母拼写。

为什么要调用
parent::User_model()在两个类中?你确定这个方法存在吗?先生,你是个英雄。非常感谢。
<?php

class User_model extends CI_Model {
    public function __construct()
    {
        // Call the CI_Model constructor
        parent::__construct();
    }
    function check_login($username, $password)
    { ....
<?php

    class User extends CI_Controller {    

        public function index()
        { ....
$autoload['model'] = array('user_model');