If you’ll be using get_instance() inside another class, then it would
be better if you assign it to a property. This way, you won’t need to call
get_instance() in every single method.

Example:

classExample{protected$CI;// We'll use a constructor, as you can't directly call a function// from a property definition.publicfunction__construct(){// Assign the CodeIgniter super-object$this->CI=&get_instance();}publicfunctionfoo(){$this->CI->load->helper('url');redirect();}publicfunctionbar(){$this->CI->config->item('base_url');}}

In the above example, both methods foo() and bar() will work
after you instantiate the Example class, without the need to call
get_instance() in each of them.