0
可能是个愚蠢的问题..但是如何正确使用类Tests中的类Test的方法而不重写它们呢?扩展时使用父类的方法
<?php
class Test {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
<?php
class Testb extends Test {
public function __construct() {
parent::__construct($name);
}
}
<?php
include('test.php');
include('testb.php');
$a = new Test('John');
$b = new Testb('Batman');
echo $b->getName();
您获得的当前输出是多少? – Achrome 2013-02-10 22:07:24
我什么都没有得到.. – Reshad 2013-02-10 22:08:33