PHP program to initialize data members without using the constructor
<?php
//PHP program to initialize data members without
//using the constructor.
class Student
{
//Attributes
private $id;
private $name;
private $per;
function Initialize()
{
$this->id = 0;
$this->name = "";
$this->per = 0.0;
}
function Display()
{
print ("Student Id : " . $this->id . '<br>');
print ("Student Name : " . $this->name . '<br>');
print ("Student Percentage : " . $this->per . '<br>');
}
}
$S = new Student();
$S->Initialize();
$S->Display();
?>
Output
Student Id : 0
Student Name :
Student Percentage : 0
