PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

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

 February 28, 2022     codeigniter, oop, php     No comments   

Issue

$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();

}

Solution

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.



Answered By - Mihai Răducanu
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing