Home >Backend Development >PHP Tutorial > 小弟我有有关问题
我有问题求助
刚接触PHP ,写了如下的一小段,$x->name();为什么打印出来是空啊?
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> interface man{ function talk(); } abstract class person{ abstract function name(); abstract function age(); var $c="这是一个抽象类<br>"; } class xiaoming extends person implements man { function name(){ echo ("xiaoming<br>"); } function age(){ echo ("12"."<br>"); } function talk(){ echo ("love<br>"); } } class xiaoli extends person implements man{ var $mingzi; function _construct($mingzi){ $this->mingzi=$mingzi; } function name(){ echo ($this->mingzi."<br>"); } function age(){ echo ("13<br>"); } function talk(){ echo ("you"); } } $p = new xiaoming(); $p->name(); $p->age(); $p->talk(); $x = new xiaoli("xiaoli"); $x->age(); $x->name(); $x->talk();