What is encapsulation with simple example in php?

前端 未结 14 1502
谎友^
谎友^ 2020-12-08 02:27

What is encapsulation with simple example in php?

14条回答
  •  不知归路
    2020-12-08 02:53

    In basic terms, it’s the way we define the visibility of our properties and methods. When you’re creating classes, you have to ask yourself what properties and methods can be accessed outside of the class. Let’s say we had a property named foo. If a class extends your class, is it allowed to manipulate and access foo? What if someone creates an instances of your class? Are they allowed to manipulate and access foo?

提交回复
热议问题