「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」ファイルはどのフォルダーに保存すればよいですか?