class Parent_class { var $first_name="David"; var $last_name="Hussey"; function __construct() { echo "Parent class object instantiated" . "</br>"; } function print_name($name,$surname) { $this->first_name=$name; $this->last_name=$surname; echo $this->first_name . " ". $this->last_name . "</br>"; } } class Child_class extends Parent_class { var $x="Roger"; var $y="Nadal"; function __construct() { echo "Child class object instantiated" . "</br>"; } function call_parent_class_function() { echo $this->x . " ". $this->last_name . "</br>"; $this->print_name($x,$y); } } $obj = new Child_class; $obj->call_parent_class_function(); $obj1 = new Parent_class; $obj1->print_name("Virat","Kohli");
<?php
?>
function call_parent_class_function() { echo $this->x . " ". $this->last_name . "</br>"; //$this->print_name($x,$y); $this->print_name($this->x,$this->y); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)