我对codeignitter -3框架很不熟悉,我正在使用像这样的控制器模型$this->load->model('model_name')
它工作得很好,我试图使用以下方式,但它抛出了一个错误,你能帮我解决这个问题吗
An uncaught Exception was encountered
Type: Error
Message: Class 'modelsTestModel' not found
TestController.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use modelsTestModel;
class TestController extends CI_Controller {
public function student(){
$obj = new TestModel();
$value = $obj->student_college();
echo $value;
}
}
你可以试试这个
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class TestController extends CI_Controller {
public function __construct() {
parent::__construct();
// Load model
$this->load->model('TestModel');
}
public function student(){
$obj = new TestModel();
$value = $obj->student_college();
echo $value;
}
}