Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is inheritance in php progaming?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of trim function in php?

1012


What is interface? Why it is used?

1078


Explain how can we execute a php script using command line?

1080


How to pass variables by references?

1037


Explain how can php and javascript interact?

1086


What is a http session?

996


Which is variable cost?

1025


What are the different types of array in php?

1028


What is the static variable in function useful for?

1019


CWD is a type of shell variable. State Whether True or False?

1156


Is it possible to destroy a cookie?

1034


What is strcmp () in php?

1024


With a heredoc syntax, do I get variable substitution inside the heredoc contents?

1154


Explain what is memcache?

1034


How is it possible to remove escape characters from a string?

1181