Objects in PHP

Object is the main entity of object oriented programming , Object are the instance of a class. That means object is the entity of class .By define a class once and then make many objects that belong to it. All object created for a same class have the identical objects i.e. every object of same class can use for the use at different places but it provide the same facility of class.
lets take an example of it:

Object is an instance of a class.

class Tv
function tv()
$this->model = “lg”;
$this->price= “2000”;

// create an object
$object = new Tv();

// show model properties
echo $object->model;

$object2= new Tv();// create another object

echo $object2->price; // show price properties


In order to get a property, we write the object name, and then dash greater than (->), and then the property name.
Note that the property name does not start with the $ sign; only the object name starts with a $.

One thought on “Objects in PHP

Leave a Reply