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();
?>
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/data-types/objects.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics