Welcome Guest, Not a member yet? Register   Sign In
Tip: Sick of get_instance()?
#1

[eluser]louis w[/eluser]
I was growing tired of having to call get_instance to get the CI super object in all my libs and the occasional view so I set up a helper. Makes calling CI so much easier.

Code:
// Add to a helper and load it from your controller
function CI() {
    if (!function_exists('get_instance')) exit('ERROR! : ' . __FILE__ .':'. __FUNCTION__ . ":: Can't get Code Igniter instance. Are you calling this function from within your application?");

    $ci =& get_instance();
    return $ci;
}

Just call CI() where ever you want to get Code Igniter.

Code:
// Example
<?=CI()->buildBreadcrumb()?>


Messages In This Thread
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 08:23 AM
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 08:43 AM
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 08:55 AM
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 09:14 AM
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 09:32 AM
Tip: Sick of get_instance()? - by El Forum - 04-08-2009, 09:54 AM
Tip: Sick of get_instance()? - by El Forum - 04-16-2009, 07:56 AM
Tip: Sick of get_instance()? - by El Forum - 04-16-2009, 08:42 AM
Tip: Sick of get_instance()? - by El Forum - 04-16-2009, 08:47 AM
Tip: Sick of get_instance()? - by El Forum - 04-17-2009, 04:53 AM
Tip: Sick of get_instance()? - by El Forum - 04-17-2009, 07:56 PM
Tip: Sick of get_instance()? - by El Forum - 04-17-2009, 11:33 PM
Tip: Sick of get_instance()? - by El Forum - 04-19-2009, 07:04 AM
Tip: Sick of get_instance()? - by El Forum - 04-20-2009, 03:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB