Program 1
<html>
<head><title>Constructor Demo</title></head>
<body>
<center>
<?php
class MyClass
{
private $rno;
private $name;
private $course;
function __construct($r,$n,$c) // Prameterized constructor
{
$this->rno=$r;
$this->name=$n;
$this->course=$c;
}
function display()
{
echo "<br>Roll No: ".$this->rno;
echo "<br>Name: ".$this->name;
echo "<br>Course: ".$this->course;
}
}
// Create object
$M1=new MyClass(501,"Rahul","MTech");
$M1->display();
$M2=new MyClass(502,"Amit Sharma","BCom");
$M2->display();
$M2=new MyClass(503,"Rajesh More","MCA");
$M2->display();
?>
</center>
</body>
</html>