A class is simply a representation of a type of object. It is the blueprint, or plan, or template, that describes the details of an object.
In PHP,A class
is a blueprint for creating an object
.
A class
can be declared using the class
keyword, followed by the name of the class and a pair of curly braces ({})
<?php class House { // code } ?>
An object is an instance of a class.
A class is the blueprint from which the individual objects are created.
We can build more than one object
from a class
.
In PHP, The new
keyword create a new instance(object) of the class,
<?php $house1 = new House(); $house2 = new House(); ?>
The process [create object from a class] is called instantiation
.