Skip to content

Commit

Permalink
employee inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
Agniprastha authored Aug 14, 2018
1 parent df08821 commit 3a72b71
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions practice/Employee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// Define a class
class Employee
{
// Declaring three protected varaibles protected $font_size;
protected $name;
protected $salary;
// Static $i=0;
// Declarte construct method which accepts three parameters and the method Addition()
function __construct($n,$s){
$this->name = $n;
$this->salary = $s;
$this->display();


}
// Declare a method for customize print
public function display(){
// $c = $this->a+$this->b;
echo"<br>Name : ".$this->name."<br> Salary : ".$this->salary;
}

}


// Define a subclass
class Mysubclass extends Employee{

}
// Create objects and passes parameters
$p = new Employee("Patil",2);

$s = new Mysubclass("Nagesh",5);
// $p->Addition();

?>



0 comments on commit 3a72b71

Please sign in to comment.