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

How to avoid the undefined index error?

984


Define object-oriented methodology?

1021


What is string and its function?

959


Is a number php?

975


Tell me how is it possible to remove escape characters from a string?

948


What is the difference between print() and echo()?

1027


Tell me how can we determine whether a variable is set?

913


How to write the form tag correctly for uploading files?

960


Why is facebook still using php?

1077


Explain Whitespace Characters?

1040


How is the comparison of objects done in php?

921


How do you use bcrypt for hashing passwords in php?

1050


Do you know what is the use of rand() in php?

977


What does $_env means?

928


What is php and why it is used?

1032