![]() |
php include vs libraries - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: php include vs libraries (/showthread.php?tid=50403) |
php include vs libraries - El Forum - 03-25-2012 [eluser]USCTrojans[/eluser] Hello, I am trying to implement a Twitter OAuth function to update posts for users. Could anyone help me with the difference between loading a library in Codeigniter and using the php "include file" Code: include base_url('application/libraries/twitter/EpiCurl.php'); This is the code I was using in my model that was going to receive the twitter information and go from there. Thanks php include vs libraries - El Forum - 03-25-2012 [eluser]skunkbad[/eluser] If you use include, it is in a sense merging the included code. If you include a class, then you would use the "new" keyword to create an instance or object. That instance exists outside of the CI super object, so you can't easily use the same instance in a model if you instantiated it from a controller, or inside a library if you included it in a model, etc, etc. unless you pass the instance as a parameter when calling a method. It just creates spagetti code. If you loaded the class using CI, you'd be able to access the instance from anywhere that the CI super object is available. There may be other benefits of using CI to load, but that's the one that I think would be most important. |