In Object Oriented Programming a class can be created by using “class†keyword followed by the name of the class.
A class is just like a blueprint for an objects.
A class can contains both “Data Members†and “Member Functions“.
A class behaves just like “Wrapper†or “Container“, in which it encapsulates “data members†and “member functions“.
When you create a variable within a class it is known as †Class Property“.
A class can create multiple “objects“.
We can access class “Properties†and “Methods†with the help of the “objects“.
Class Objects are also known as “Class instance“.
“new†keyword is used to create an object/instance of the class.
<?php // Class definition class Books{ /* Member function */ public function name(){ echo "PHP book"; } /* Member function */ public function price(){ echo "900 Rs/-"; } } // To create php object we have to use a new operator. // Here php object is the object of the Books Class. $obj = new Books(); //$obj is an object of class Books. echo $obj->name(); //$obj access name property of class Books echo "<br>"; echo $obj->price(); //$obj access price property of class Books ?> ------------ ****** ------------ OUTPUT: PHP book 900 Rs/-