Extends class in php with multiple object
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>oops in php by saddam</title>
</head>
<body>
creat many object in one class
<?php
class collage
{
public $name, $age, $clss,$address;
function __construct($n,$a,$c,$ad)
{
$this->name=$n;
$this->age=$a;
$this->clss=$c;
$this->address=$ad;
}
}
class student extends collage
{
function __construct( )
{
parent::__construct("saddam","15","12","delhi");
}
function index()
{
echo "</br></br>saddam used OWERWRITE code for __construct function and parent keyword</br></br>";
}
}
$obj1= new student;
$obj1->index();
?>
output:- should be like this :-
saddam used OWERWRITE code for __construct function and parent keyword;
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>oops in php by saddam</title>
</head>
<body>
creat many object in one class
<?php
class collage
{
public $name, $age, $clss,$address;
function __construct($n,$a,$c,$ad)
{
$this->name=$n;
$this->age=$a;
$this->clss=$c;
$this->address=$ad;
}
}
class student extends collage
{
function __construct( )
{
parent::__construct("saddam","15","12","delhi");
}
function index()
{
echo "</br></br>saddam used OWERWRITE code for __construct function and parent keyword</br></br>";
}
}
$obj1= new student;
$obj1->index();
?>
output:- should be like this :-
saddam used OWERWRITE code for __construct function and parent keyword;
</body>
</html>
Comments
Post a Comment