What is Encapsulation in PHP- Tutorialpath


PHP Encapsulation
PHP Encapsulation

Welcome to all our readers on our website at www.tutorialpath.com. As you all know that here on our website we will provide you lots of information related to the latest and newly introduced technology which help you to get updated with the latest tech. Here you will get all the useful information which is required in this tech world. As you know technology is one of the trending part in this world. So, here again we came up with a latest and new tech information which is related to the process of creating Encapsulation in PHP. With the help of this article you will get to know the complete process of how to create Encapsulation in PHP a step by step manner. So, simply have a look to this article and grab all the useful information which is going to be very helpful for you.

what is encapsulation in php

Encapsulation is a concept of wrapping up or binding up related data members and methods in a single module is known as encapsulation

And hiding the essential internal property of that module known as data abstraction.

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.



Encapsulation output
Encapsulation output


Create a arithmetic class with add( ),sub( ),mult( ) and div( ) method

Encapsulation 1


Encapsulation output1
Encapsulation output 1

Difference between Encapsulation and Abstraction

Abstraction Encapsulation
Abstraction solves the problem in the design level. Encapsulation solves the problem in the implementation level.
Abstraction is used for hiding the unwanted data and giving relevant data. Encapsulation means hiding the code and data into a single unit to protect the data from outside the world.
Abstraction lets you focus on what the object does instead of how it does it. Encapsulation means hiding the internal details of mechancis of how an object does something.
Abstraction:- Outer layout, used in term of design.


Outer Look of a mobile phone, like it has a display screen and keyword buttons to dial a number.

Encapsulation:- Inner layout, used in term of implementation.


Inner implementation detail of a mobile phone, how keyword button and display screen are connect with each other using circuit.


So, hopefully we had shared all the basic steps which help you to Encapsulation in PHP. If you are using any of the above given browser and the steps helps you to enable or disable the JavaScript then simply share this article with others and also tell us by dropping a comment in the comment section below so that we get to know how helpful this article is for you all.

2 thoughts on “What is Encapsulation in PHP- Tutorialpath

Leave a Reply

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