• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use of Helper and libraries

#1
Hi,
 
can any one explain difference between helpers and libraries? I know that helpers are the function and libraries are the class but what is best practice to you use them?

Thanks.
Reply

#2
Helpers are method/functions where Libraries are classes with methods/functions
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#3
http://www.webdeveloper.com/forum/showth...-Functions
Reply

#4
(08-29-2017, 11:03 AM)InsiteFX Wrote: Helpers are method/functions where Libraries are classes with methods/functions

Thanks for reply. I know basic diffrence but in which situation we use helper and in which situation we use  Libraries.
Reply

#5
A CodeIgniter helper is a set of related functions (Common functions) which you could
use them within Models, Views, Controllers,.. everywhere. Once you load (include) that file,
you can get access to the functions. But a Library is a class, which you need to make an
instance of the class (by $this->load->library()).

Helpers can be used in any place.

For example I created my own asset_help that allows be to use the
base_url() for resources like css js etc; I autoload the helper and
can use it in my views for setting my css and js paths to the files.

Functions do one thing and do it great, my_function();
Compared to libraries do multiple things with one load instance.
$this->library_name->function();

Easier typing and less memory depending on the size of the files.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#6
(09-01-2017, 04:16 AM)InsiteFX Wrote: A CodeIgniter helper is a set of related functions (Common functions) which you could
use them within Models, Views, Controllers,.. everywhere. Once you load (include) that file,
you can get access to the functions. But a Library is a class, which you need to make an
instance of the class (by $this->load->library()).

Helpers can be used in any place.

For example I created my own asset_help that allows be to use the
base_url() for resources like css js etc; I autoload the helper and
can use it in my views for setting my css and js paths to the files.

Functions do one thing and do it great, my_function();
Compared to libraries do multiple things with one load instance.
$this->library_name->function();

Easier typing and less memory depending on the size of the files.

Thanks buddy for  details.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.