php抽象类的实例代码,如下:
<?php
/**
* 定义与使用php抽象类
* edit: www.jb200.com
*/
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 */
?>