why i get nothing while extending 2 classes?
Posted: Mon Sep 12, 2005 2:26 am
person.php
male.php
female.php
manypeople.php
while i view my "manypeople.php" it shows me nothing, why?but if i remove at leat one class files like male or female then i get the one out put correctly. Any body please help me understand the concept of extends.
Code: Select all
<?php
class person{
private $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
function getName(){
return $this->name;
}
function getAge(){
return $this->age;
}
}
?>Code: Select all
<?php
include "person.php";
class male extends person{
private $sex = "Male";
function __construct($name,$age){
parent::__construct($name,$age);
}
function getGender(){
return ($this->sex);
}
}
?>Code: Select all
<?php
include "person.php";
class female extends person{
private $sex = "Female";
function __construct($name,$age){
parent::__construct($name,$age);
}
function getGender(){
return ($this->sex);
}
}
?>Code: Select all
<?php
include "female.php";
include "male.php";
function dPerson($any){
print($any->getName()." is ".$any->getAge()." years old and is a ".$any->getGender().".<br>");
}
$tara = new female("Tara",28);
dPerson($tara);
$joe = new male("Joe",30);
dPerson($joe);
?>