Quick Answer
public: accessible from anywhere (outside the class, subclasses, same class). protected: accessible within the class and its subclasses. private: accessible only within the same class - not even subclasses. Apply to properties and methods. Default is public in PHP. Use private for internal implementation, protected for extensible behavior, public for the class's interface.
Answer
public is accessible everywhere, private only inside the class, protected inside the class and subclasses.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.
PHP interview questions and answers for beginner, junior, mid-level, senior, and expert developers. Ideal for freshers and experienced candidates preparing for PHP roles.