Reputation: 963
$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();
}
Upvotes: 4
Views: 22826
Reputation: 359
load
is a class belongs to the loader class
codeigniter official documentation
view
, model
and others are methods
Upvotes: 0
Reputation: 12585
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.
Upvotes: 8
Reputation: 8964
In the context of a class that extends CI_Controller
(in other words: a controller) the symbol $this
is the Codeigniter "super object". Which is, more or less, the central object for CI sites and contains (among other things) a list of loaded classes. load
is one of the classes you'll always find there because it is automatically loaded by the CI system.
Technically, the class creates objects of the type CI_Loader
. view()
is just one of the many methods in the load
class. Other commonly used class methods are model()
, library()
, config()
, helper()
, and database()
. There are others.
So, in short, load
is a class used to load other resources.
Upvotes: 0
Reputation: 1273
Your controller inherits CI_Controller
. So, if you look in application/system/core/Controller.php
you'll find something interesting : $this->load =& load_class('Loader', 'core');
(l.50 with CI2). So, $this->load refer to the file application/system/core/Loader.php
which have a function public function view
(l.418 with CI2)
Upvotes: 2