I'm a little confused how the library and helper methods are used in a code igniter. I am still learning code igniter.
CONTROLLER
function index(){ $this->load->helper('text'); $this->load->library('auth'); //custom library $data['string'] = 'this is sample ..... this is sample'; $this->load->view('article', $data); }
BROWSE
<?php if(is_logged_in()){ //is_logged_in() is the method from the library, 'auth' echo 'You are logged in'; } <p><?php echo word_limiter($string, 10); ?></p> <!--word_limiter() is the method from the helper, 'text' -->
In the above view file, the helper method word_limiter() works fine. But the is_logged_in() method does not work. But if I do this ( $this->auth->is_logged_in() ), it will work.
But why is the method from a helper, i.e. word_limiter() , no need to write like this ( $this->text->word_limiter() ).
Is there a difference between helper method and library?
php codeigniter codeigniter-2 codeigniter-helpers
Nirmalz thapaz
source share