Welcome Guest, Not a member yet? Register   Sign In
php include vs libraries
#1

[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');
  include base_url('application/libraries/twitter/EpiOAuth.php');
  include base_url('application/libraries/twitter/EpiTwitter.php');

This is the code I was using in my model that was going to receive the twitter information and go from there.

Thanks
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB