The source code to print the size of the empty class is given below. The given program is compiled and executed successfully.
<?php
//PHP program to print the size of the empty class.
class Student
{
}
$S = new Student();
echo "Size of object: " . sizeof($S);
?>
Output:
Size of object: 1
Explanation:
In the above program, we created an empty class Student. After that we created the object "$S" of the Student class and then print the size of the object, it will print 1, because the size of an empty class always one to differentiate the address space for objects.
Program/Source Code:
The source code to print the size of the empty class is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created an empty class Student. After that we created the object "$S" of the Student class and then print the size of the object, it will print 1, because the size of an empty class always one to differentiate the address space for objects.
need an explanation for this answer? contact us directly to get an explanation for this answer