What are the main principles of OOP

Object-Oriented Programming (OOP) is a programming paradigm centered around the concept of "objects," which can encapsulate data and functionality. The main principles of OOP include Encapsulation, Inheritance, Polymorphism, and Abstraction. These principles help in designing software that is modular, reusable, and easier to maintain.
OOP, Object-Oriented Programming, Encapsulation, Inheritance, Polymorphism, Abstraction
<?php // Class definition (Encapsulation) class Animal { public $name; public function __construct($name) { $this->name = $name; } public function makeSound() { return "Some sound"; } } // Inheritance class Dog extends Animal { public function makeSound() { return "Bark"; } } class Cat extends Animal { public function makeSound() { return "Meow"; } } // Polymorphism function animalSound(Animal $animal) { return $animal->makeSound(); } $dog = new Dog("Rover"); $cat = new Cat("Whiskers"); echo animalSound($dog); // Outputs: Bark echo animalSound($cat); // Outputs: Meow ?>

OOP Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction