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 |
What is meant by variable variables in php?
Tell me how to create a session? How to set a value in session? How to remove data from a session?
1.Where are the cookies storing ? 2.What is the drawback of using cookies ? 3. If two site is having same cookie name and different values what will be the output if we echo the cookie name from those sites ? How can we solve this issue (How can we specify the domain name)?
Which is the correct way to check if a session has already been started ?
Write the statements that are used to connect php with mysql
How to copy a file?
Can the value of a constant change during the script's execution?
How do you parse and process html/xml in php?
i want to store retrieved data from database into an array list with limit.And display the data from that array list.have any answer for this?
Why do we show php code in browser?
Which is not a file-related function in php?
How to break a file path name into parts?