Creating a Class That Inherits from Another : Class Inheritance : Class PHP Source Code


PHP Source Code » Class » Class Inheritance »

 

Creating a Class That Inherits from Another



<html>
<head>
<title>Creating a Class That Inherits from Another</title>
</head>
<body>
<?php
class FirstClass{
    var $name = "first class";
    function FirstClass$n ){
        $this->name = $n;
    }
    function sayHello(){
        print "my name is $this->name<br>";
    }
}

class second_class extends FirstClass{

}

$test = new second_class("inherited");
$test->sayHello();

?>
</body>
</html>


           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Class Inheritance