PHP Data Types : Objects


An object is a data type which stores not only data but also information on how to process that data. Unlike the other data types in PHP, an object must be explicitly declared.

At first, we must declare a class of object. A class is a structure which contains properties and methods.

Classes are defined with the class keyword. We define the data type in the object class, and then we use the data type in instances of that class.


<?php class student
function marks_calculation()
echo "Display marks";
$student1 = new student;

Previous: Arrays
Next: NULL

Follow us on Facebook and Twitter for latest update.