Monday 8 February 2016

Inheritance in PHP

Code:

<?php
echo "<center><h1>Inheritance in PHP</h1>";
class Person
{
    public $name="Dominic Toretto";
}
class human extends Person
{
    public function Greet()
    {
        return "My name is " . $this->name;
    }
}
$person = new human();
echo $person->Greet();
echo "</center>";
?>



Output:


No comments:

Post a Comment