Object-Oriented Programming Concepts in PHP
PHP is a server-side scripting language, mainly used for web development but also used as a general-purpose programming language. Object-Oriented Programming (PHP OOP), is a type of programming language principle added to php5, that helps in building complex, reusable web applications.
In this blog, we will be explaining some of the Object-Oriented Programming concepts in PHP with some examples.
The Object Oriented concepts in PHP are:
- Class
- Objects
- Inheritance
- Interface
- Abstraction
- Magic Methods
Class & Object:
- Class is a programmer-defined data type, which includes local methods and local variables.
- Class is a collection of objects. Object has properties and behaviour.
- First we have to define a php class, where classname should be same as filename.
Example for simple class: