w3resource
PHP Tutorial

PHP Data Types : Objects

Description

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.

Example:

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

Previous: Arrays
Next: NULL



New Content: Composer: Dependency manager for PHP, R Programming