PHP Object Oriented Programming - What is OOP?
You can now create PHP code in an object-oriented approach starting with PHP5.
Object-Oriented Programming is referred to as OOP.
While procedural programming involves writing procedures or functions that execute operations on data, object-oriented programming involves constructing objects that include both data and functions.
In comparison to procedural programming, object-oriented programming provides various benefits :
- Object-Oriented programming is more efficient and straightforward to use.
- OOP gives the programs a distinct structure.
- As a result of OOP, PHP code becomes more maintainable, modifiable, and debuggable.
- With OOP, you may construct fully reusable apps with less code and less time spent on development.
Tip : The "Don't Repeat Yourself" (DRY) approach focuses on reducing code repetitions. Use a single location to store and reuse the common code for your application, rather than repeating the same code over and over again.
Related Links
PHP - What are Classes and Objects?
Object-oriented programming is divided into two parts : classes and objects.
To understand the distinction between class and object, consider the following illustration :
As a result, a class is a template for objects, and an object is a subset of class.
When separate objects are formed, they inherit all of the class's attributes and behaviours, but the properties will have distinct values for each object.
Related Links