php extends problem
Posted: Sun Jul 13, 2008 8:56 pm
hello everyone
This is my code
my problem is the extends class girl have private school and I create an new class nancy
why do not output 'why not out put' ,this set in the base class
This is my code
Code: Select all
<?php
class people{
private $names;
private $age;
private $test;
/**/
function __construct($names__="",$age__=""){
$this->names=$names__;
$this->age=$age__;
}
/**/
/**/
private function __get($w){
echo '<font color=blue>get</font>';
return $this->$w;
}
/**/
private function __set($what_names,$what_value){
echo '<font color=red>set</font>';
$this->$what_names=$what_value;
}
}
class girl extends people{
private $school;
}
/**
$mary=new people('mary_wang','22');
//$mary->names='jerry';
$mary->test='test out put';
echo $mary->test;
echo '<b>'.$mary->names.'</b>';
echo '<b>'.$mary->age.'</b>';
/**/
/**/
$nancy=new girl('nancy_chen','14');
$nancy->school='why not out put';
echo $nancy->school;
echo '<b>'.$nancy->names.'</b>';
echo '<b>'.$nancy->age.'<b>';
/**/
?>why do not output 'why not out put' ,this set in the base class