1.

What is the difference between public, protected and private?

Answer»

PHP has three access modifiers such as public, private, and protected.

  • public scope of this variable or function is available from anywhere, other classes, and instances of the object.
  • private scope of this variable or function is available in its class only.
  • protected scope of this variable or function is available in all classes that EXTEND the current class including the parent class.

Note: One of the most TRICKY oops interview questions in php, you need to answer this question with utmost clarity. Maybe explaining it with a short example or even a dry RUN would help you GET that dream job.



Discussion

No Comment Found