$this Keywords in Opps

In this tutorial, you will learn about PHP $this keyword and how to use $this inside a class.



In PHP, $this keyword references the current object of the class

Here we can get a clear idea about $this keyword, Here the price of the car can access by the keyword $this, can not access outside the class.


 

Questions asked in the Interview on $this



  1. What is $this
    Answer –  $this is a keyword in PHP
  2. How $this is used in Oops
    Answer –  This is used inside the class as a current object of the same class. By using $this we can access member functions and member variables inside the same class, outside access will show fatal error.

 

Tags: , ,