Tuesday, 20 March 2012

INHERITANCE

<html>
<head>
<title>Example:1</title>
</head>
<body>
<?php
class first_class
{
var $name = "harry";
function first_class($n)
{
$this->name =$n;
}
function sayHello()
{
print "Hello my name is $this->name<br>";
}
}
class second_class extends first_class
{
}
$test = new second_class("son of harry");
$test->sayHello();
 ?>
</body>
</html>

OUTPUT
Hello my name is son of harry

No comments:

Post a Comment