Skip to content
Advertisement

what is $this->load->view() in CodeIgniter

$this is use for current class and view is method but what is load. Is this a property?

Is this example correct?

class super{

    public $property;

    public function superf1()
    {
        echo "hello";
    }
    public function col()
    {
        $this->superf1();
    }

    $this->property->super1();

}

Advertisement

Answer

Yes, load is a property. Think of it like this:

class Loader {
    public function view() {
        //code...
    }
}

class MyClass {
     private $load;

     public __constructor() {
         $this->load = new Loader();
     }

     public someMethod() {
         $this->load->view();
     }
}

This syntax is called chaining.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement