hi everybody !
I'm new in PHP and codeIgniter and i have an issue with my code.
I'm trying to clean my view method by stocking some helpers in extern method.
So, instead to have:
public function index(){
$this->load->helper('url');
$this->load->helper('form');
$this->load->model('Users_model');
$data['records'] = $this->Users_model->getData();
$this->load->view('templates/header');
$this->load->view('users', $data);
$this->load->view('templates/footer');
}
i want to do this:
public function index(){
loaderMethod();
$data['records'] = $this->Users_model->getData();
$this->load->view('templates/header');
$this->load->view('users', $data);
$this->load->view('templates/footer');
}
public function loaderMethod(){
$load = array(
"$this->load->helper('url');",
"$this->load->helper('form');",
"$this->load->model('Users_model');"
);
return $load;
}
i know that stocking these ligns in an array it's a bad idea, but it was for show you that i'm trying to do.
If u have some ideas to give, it will be a pleasure !