PHP 5 中引入了抽象类及方法的概念。 An abstract
method only declares the method's signature and does not provide an
implementation. A class that contains abstract methods needs to be declared
abstract.
例子 19-6. 抽象类代码实例
<?php
abstract class AbstractClass {
abstract public function test();
}
class ImplementedClass extends AbstractClass {
public function test() {
echo "ImplementedClass::test() called.\n";
}
}
$o = new ImplementedClass;
$o->test();
?>
|
|
抽象类不能被实例化。Old code that has no user-defined
classes or functions named 'abstract' should run without modifications.