From PHP 5 onwards, you can write PHP code in an Object-Oriented Programming (OOP) style. Object-Oriented Programming is a programming paradigm that revolves around the concept of "objects", which contain both data and the functions that manipulate that data.
Before OOP, PHP was primarily written using Procedural Programming.
OOP is the industry standard for modern web applications because it provides several massive advantages:
To understand OOP, you must understand the difference between a Class and an Object.
Think of a Class as a blueprint or a template, and an Object as an instance of that blueprint.
A "Fruit" has properties like color and weight. An "Apple" is an object created from the Fruit class, and we can define its specific color as Red and its weight as 150g.
When the individual objects are created, they automatically inherit all the properties and behaviors from the class, but they can have different values assigned to their properties.
In Object-Oriented Programming, what is considered the "blueprint" from which individual items are created?