Concept of Encapsulation in PHP OOP – onlinecode

Concept of Encapsulation in PHP OOP – onlinecode

In this post we will give you information about Concept of Encapsulation in PHP OOP – onlinecode. Hear we will give you detail about Concept of Encapsulation in PHP OOP – onlinecodeAnd how to use it also give you demo for it if it is necessary.

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.

  1. class Bag{
  2. pen();// calling function of pen
  3. readBook();//calling function of read book
  4. }
class Bag{pen(); // calling function of penreadBook(); //calling function of read book}

Label :



Object Oriented Programming

Web Development

Hope this code and post will helped you for implement Concept of Encapsulation in PHP OOP – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  62  =  67

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US