Encapsulation in PHP It is a concept of wrapping up or binding up related data members and methods in a single module known as Encapsulation.
Wrapping up data member and method together into a single unit is called Encapsulation
Example:
<?php
class Car {
private $brand; // Private property
public function getBrand() { return $this->brand; }
public function setBrand($brand) { $this->brand = $brand; }
}
$car = new Car();
$car->setBrand("Toyota");
echo $car->getBrand();
?>
Output:
Toyota