Silly question I know,
From all the tutorials they do not explain why they use $this.
Is $this like an object from a base class in Codeigniter?
Any e
$this
isn't something from CodeIgniter, but from PHP. $this
refers to the current object.
Whenever you create an instance like this:
$something = new SomeClass();
Then $this
refers to the instance that is created from SomeClass
, in this case $something
. Whenever you are in the class itself, you can use $this
to refer to this instance.
So:
class SomeClass {
public $stuff = 'Some stuff';
public function doStuff()
{
$this->stuff;
}
}