简体   繁体   中英

Different ways of loading libraries in CodeIgniter

What is the difference of loading a library in CodeIgniter via,

  1. autoload.php
  2. Controller class

Is there any point in loading the library in the constructor method of the controller class as,

$this->load->library(array('form_validation'));

when I can just load them at the autoload.php?

Thank you!

Not loading all libraries in autoload is simply for performance reasons. If you rarely use a certain library, you might want to load it only when using it's relevant controller. Autoloading every library all the time could be "wasteful".

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM