After the introduction of object oriented approach in PHP, many keywords are being used in programming PHP applications. Few of them are straight forward as any other language and few others are just confusing. Today I am going to discuss such confusing elements of PHP OOP. Following is a quick list on what you find in this post.
- $this
- self::
- parent::
- static::
$this Operator in PHP
It is used to access the properties and methods of the same class inside a method.
Example:
class example1
{
public $name = "Sachin";
public function ShowName()
{
echo “ The Name is : “. $this->$name;
}
}
The self:: operator
This is same as that of $this with a small difference. It is used to access propertis and methods in cases where both of them are declared with static keyword.
