Php 致命错误:调用未定义的方法CI_Model::User_Model()
有人知道我如何摆脱这个错误吗:“致命错误:调用未定义的方法CI_Model::User_Model()” 这是我的user.phpPhp 致命错误:调用未定义的方法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();
<?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');