hi, All.
I know that how to use public, protected and private variables.
for ex: public i can use it another class, protected i can use in main and being inherited class and private only the class where it declared.
but i dont understand what is purpose to it public, private, or protected. what does it mean?

It's for example to show other coders that are working on the same project as you how they should use your class.

Public == Available to everyone who can access the class
Private == Available only within the class where the function/variable is
declared
protected = Available only within the class, or any class that is derived
from the class

Let me know if you need more :)

Thank you very much. I understood the visibility (public, protected, private) of these fields. but i didnt understand for what reason and where are used these visibility methods?

Thank you very much. I understood the visibility (public, protected, private) of these fields. but i didnt understand for what reason and where are used these visibility methods?

This gives you the flexibility advantages in your coding. you might want to read more here

http://php.net/manual/en/language.oop5.visibility.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.