PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
include "person.php";
class male extends person{
private $sex = "Male";
function __construct($name,$age){
parent::__construct($name,$age);
}
function getGender(){
return ($this->sex);
}
}
?>
<?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);
?>
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.
that should be similar to what you'll find in your error logs. Reason why: you have included person.php twice. Either use include_once(), or use the __autoload() magic function, or write person.php to know not to redefine itself..