난 그냥 이런 식으로 코드를 작성 :이 오류의 첫 번째 부분을 이해추상 클래스 메소드 선언
Fatal error: Class test contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (test::getValue, test::prefixValue) in C:\wamp64\www\study\abstract.php on line 12
:이 코드를 실행하면
<?php
class test
{
// Force Extending class to define this method
abstract protected function getValue();
abstract protected function prefixValue($prefix);
// Common method
public function printOut() {
print $this->getValue() . "\n";
}
}
class testabs extends test{
public function getValue()
{
}
public function prefixValue($f)
{
}
}
$obj = new testabs();
?>
, 나는 아래의 오류가 발생했습니다. 클래스 테스트를 추상으로 변경했는데 오류가 사라졌지 만 or
부분은 이해할 수 없습니다.
_or_ 부분은 클래스가 'test' 클래스를 확장하는 관점에서입니다. 그것은 양방향으로 진행됩니다. 당신의'test' 클래스를 추상화 시키거나 상속 된 추상 선언을 구현하지 않기 때문에'test' 추상을 확장하는 다른 클래스를 만드십시오. – dbf