What is inheritance in php progaming?
Answer / dhanya
Inheritance is the extension of a class. A child class has
all the properties and methods of its parent class. For
example, pets generally share similar characteristics,
regardless of what type of animal they are. Pets eat, and
sleep, and can be given names. However the different types
of pet also have their own methods: dogs bark and cats meow.
Below is an implementation of this:
<?php
class Pet
{
var $_name;
function Pet($name)
{
$this->_name = $name;
}
function eat()
{
}
function sleep()
{
}
}
class Dog extends Pet
{
function bark()
{
}
}
class Cat extends Pet
{
function meow()
{
}
}
$dog = new Dog("Max");
$dog->eat();
$dog->bark();
$dog->sleep();
$cat = new Cat("Misty");
$cat->eat();
$cat->meow();
$cat->sleep();
?>
| Is This Answer Correct ? | 1 Yes | 0 No |
Which is better get or post method?
What is the difference between characters 34 and x34?
What is the purpose of the '.myd' file extension? What do thes file contain?
What is mysql in php?
equivalent code for the following c program in php void main() { int i=5;printf("%d",i); }
What is lamp in php?
Under what circumstance is it impossible to assign a default value to a parameter while declaring a function?
Tell me what are the encryption techniques in php?
How to list all values of submitted fields?
Does jwt protect against csrf?
we have two tables first one is EMPLOYEE having EmpID, EmpNAME, Second table is SALARY table having id, salary Write a query to get name of those person who having more than 10000$ salary
How to store the uploaded file to the final location?