CodeIgniter Forums
undefined function get_instance() ? - 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: undefined function get_instance() ? (/showthread.php?tid=37392)



undefined function get_instance() ? - El Forum - 01-07-2011

[eluser]Tom Vogt[/eluser]
Why does the get_instance() call in following code not work? It tells me "undefined function get_instance()" and I don't understand why:

Code:
class MY_Language extends CI_Language {

    public $ci;

    public function __construct() {
        parent::__construct();
        $this->ci =& get_instance();
    }



undefined function get_instance() ? - El Forum - 01-08-2011

[eluser]InsiteFX[/eluser]
Not sure if you posted all of your controller code?

But your class is missing the closing }

InsiteFX


undefined function get_instance() ? - El Forum - 01-08-2011

[eluser]Tom Vogt[/eluser]
I posted only the first part, of course there's additional code below this, including the closing bracket. :-)


undefined function get_instance() ? - El Forum - 01-08-2011

[eluser]gRoberts[/eluser]
It's most likely because parent::Controller() hasn't been called before your MY_Library file has been called.

I've had this problem when trying to use any CI related functions before calling it.


undefined function get_instance() ? - El Forum - 01-08-2011

[eluser]Cristian Gilè[/eluser]
http://ellislab.com/forums/viewthread/129747/#641022

Cristian Gilè