Welcome Guest, Not a member yet? Register   Sign In
& get_instance() vs $this


Refers to the current class. Only used in classes that are instantiated, meaning not in static classes. Static classes use "self".

$CI =& get_instance();

$CI is the CodeIgniter super object. All classes loaded though the CI Loader end up being usable through the super object. The super object is more or less a "service locator".

Special Note:

It happens that when in a controller or model, the controller or model has access to the CodeIgniter super object through $this. It may seem confusing, but that's why your controllers extend CI_Controller, and your models extend CI_Model.

Messages In This Thread
& get_instance() vs $this - by rahulemaity - 06-08-2017, 11:43 AM
RE: & get_instance() vs $this - by NickOver - 06-08-2017, 01:09 PM
RE: & get_instance() vs $this - by skunkbad - 06-08-2017, 04:19 PM

Theme © iAndrew 2016 - Forum software by © MyBB