i try load custom helper but it is not load and generate error like this
An Error Was Encountered
Unable to load the requested file: helpers/getdata_helper.php
my helper is stored in
Application/helper/getdata.php
my controller is
class home extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('home_model'); $this->load->helper(array('url','form','language','string')); $this->load->helper('getdata'); //$this->EE->load->helper('menu_load'); } public function index() { $menu['menu']=$this->home_model->get_menu(); $menu['print_menu']=$this->echoMenu($menu['menu']); $data['latest']=$this->home_model->get_latest_product(); $this->load->view('header_1',$menu); $this->load->view('index',$data); $this->load->view('footer'); }
Let's see what des doc says :
Loading a helper file is quite simple using the following function: $this->load->helper('name');
Where name is the file name of the helper, without the .php file extension or the "helper" part.
For example, to load the URL Helper file, which is named url_helper.php, you would do this: $this->load->helper('url');
It clearly suggests that CI will look for a file named xxx_helper.php. In you case, when load getdata
, CI will look for getdata_helper.php
inside application/helpers
.
You just have to rename your file to make it work.
It shouldn't give a error. Anyways try to auto load it like:
$autoload['helper'] = array('getdata');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.