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