Object oriented programming (OOP) has been supported by PHP since version 3 and improved a lot in version 5. The main difference between OOP and functional programming is that, in OOP data and code are grouped together into one entity which is known as object. An OOP application usually has a group of related objects interacting with each other. Object includes data known as properties and methods which are functions of object.
In order to create an object we need a blueprint of object which is so called class. Class is a template for an object and describe which methods and properties object can have. In PHP, to create a class we use class keyword followed by class name. For example we here is the class Shape in PHP
In the above example, we have a Shape class with a property called color. In Shape class we have two methods to get and set color property. It is common practice to access property of class via get / set methods. Then we create two objects which type are Shape class. Be noted that operator new is used to create an instance of class. We then can call the method of class via operator ->.