PHP OOP This Keyword

PHP OOP $this Keyword

$this keyword is used to refer to the current object. It is only available inside the method of the class. Basically, it refers to the object of the current method.

How To Access Class Property & Method

The general syntax for accessing class property and method.


Note:Please keep in mind that, Only the $this keyword starts with the $. sign. Do not specify the $ sign before the property and method name.

Followings are the invalid syntax.


Source Code

Try it now