/** * 定义与使用php抽象类 * edit: bbs.it-home.org */ abstract class Number { private $value; abstract public function value(); public function reset() { $this->value = NULL; } } class Integer extends Number { private $value; public function value() { return (int)$this->value; } } $num = new Integer; /* Okay */ $num2 = new Number; /* This will fail */ ?> 复制代码