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

When should we use $this and when & get_instance()?I have a library file .The code is
class Test {

public function testf()
    echo 1;
Now I load the library in my controller function

Now in my view if we write $this->test->testf();.We get result 1;
Now the fact is I load the library in view file.Then it give error Undefined property: CI_Loader.
if we create an instance in view then its woking properly.like 
$ci=& get_instance();
then it gives result 1;
My question is where to use $this and where to & get_instance();

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