Objects in PHP: Creating and Using Objects
☰Fullscreen
Table of Content:
An object is a data type that stores data and information on how to process that data.
In PHP, an object must be explicitly declared.
First, we must declare a class of objects. For this, we use the class keyword. A class is a structure that can contain properties and methods:
Example Code:
model = "Model Z.10"; } } // create an object $carObj = new Car(); // show object properties echo $carObj->model; ?>
Output:
The above code will produce the following result-
Model Z.10