OOPS: Classes in php

OOPS Concept: Introducing Classes in php


You all know that Classes are the most important part of OOP.


A class is simply a template or blueprint that contains the various attributes and functions of an object of the class.
Class is mainly composed of three things :  name, attributes, and operations.We can also say that class is a composite data type same as we have used struct in C and C++.


Class would be the type, and an object would be the variable. eg.


Consider a class Car.
A car class will have the following attributes:

1. Color
2. Engine
3. Tyres
4. Headlights
5. Seats
6. Steering

It will also have the following function/operations
1. Power Brake
2. Blow Horn
3. Pickup and Drive etc


A class gives you only the attributes and function.

Lets think in general there are so many company manufacture the car,they can increase the function and attributes. After putting all these in a real world then a car make up,then it’s called object(real entity),the base or template or blueprint is car,so car is a class.


In real world, you’ll often find many individual objects all of the same kind. As an example, there may be thousands of other bikes, all of the same make and model. Each bike has built from the same blueprint. In object-oriented terms, we say that the bike is an instance of the class of objects known as bikes.