Access Specifiers

Last updated

What is Access Specifiers?

Access specifiers, also known as access modifiers, in PHP are keywords used in the class context which define the visibility and accessibility of properties, methods and constants. PHP supports three types of access specifiers: public, private, and protected. 'Public' specified properties or methods can be accessed from anywhere, 'private' ones can only be accessed within the class that defines them, while 'protected' ones can be accessed within the class itself and by inherited and parent classes. Here's an illustrative example:

Free resources to learn Access Specifiers

More in stage 11: OOP Fundamentals

Access Specifiers: common questions

Can I learn Access Specifiers in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Access Specifiers in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Access Specifiers tutorial for beginners?

It is lesson 64 of 120 in the free PHP roadmap, in stage 11, OOP Fundamentals. If you are new to PHP, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me