Concept of Encapsulation in PHP

Concept of Encapsulation in PHP

Concept of Encapsulation in PHP?

Encapsulation is an OOP (Object Oriented Programming) concept in PHP.

Wrapping some data in single unit is called Encapsulation. Encapsulation is used to safe data or information in an object from other it means encapsulation is mainly used for protection purpose.

In technology era, it is essential to maintain your privacy. So for the security reason, Sometime we make private method.

Private method means it can be accessed within same class. Outside, Class can't access private method of other class.That's why encapsulation is known as data hiding is the main advantage for encapsulation.

Second advantage of encapsulation is you can make the class read only or write only by providing setter or getter method.

Capsule is best example of Encapsulation. Capsule basically encapsulate several combination of medicines. Schoolbag is one of best example of Encapsulation. School bag can keep our books, pen etc.

So finally the concept of Encapsulation in PHP is hiding internal information of object to protect from the other object.

Phone: (+91) 8800417876
Noida, 201301