PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<Object ConstantsObject Interfaces>
Last updated: Mon, 16 Jul 2012

抽象类

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.




<Object ConstantsObject Interfaces>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST