An Object is an instance of class. PHP Object is used to access properties and methods of class.
A variables are called properties and functions are called methods in class. We can call member methods of class using object.
We can create multiple objects from a class. Each object will have different property values.
We can create new object using "new" operator as per as below.
Object variable name = new keyword class name;
//code to be executed!
$obj= new Class_name;
new keyword is used to allocate memory for object.
PHP Example :
$cricket = new Game();
$hockey = new Game();
$football = new Game();
echo "</br>I would like to play ".$cricket->get_game();
echo "</br>I would like to play ".$hockey->get_game();
echo "</br>I would like to play ".$football->get_game();
I would like to play Cricket
I would like to play Hockey
I would like to play Football