我从控制器调用的“custom_functions.php”中有一些自定义函数。
我的“custom_functions.php”代码如下:
class Custom_functions extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('model');
$this->load->library('session');
}
public function data($first, $next) {
// other codes start from here
}
}
我将该文件保存在应用程序/库中并加载到控制器中:
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('model');
$this->load->library('pagination');
$this->load->library('custom_functions');
}
// other codes start from here
}
然后我的自定义功能起作用了,但分页不起作用。
我收到一条错误消息:
A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Loader::$pagination Filename: views/index.php Line Number: 27
而视图文件第 27 行是:
echo $this->pagination->create_links();
如果我删除
$this->load->library('custom_functions');
然后分页线工作。为什么会这样?我加载自定义函数是否做错了,或者我将自定义函数保存在错误的文件夹中?我应该将“custom_functions.php”文件保存在哪个文件夹中?