What is the difference between public, protected and private?
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.
BY Best Interview Question ON 06 Jul 2020