我有一个实现几个抽象方法的类.当我扩展该类时,我得到以下致命错误消息:
Class CI_Controller_Rest contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods
抽象方法的类:
class CI_Controller_Rest extends CI_Controller { public function __construct() { parent::__construct(); } abstract public function index(); abstract public function get(); abstract public function head(); abstract public function post(); abstract public function put(); abstract public function delete(); }
我扩展CI_Controller_Rest的类:
class Welcome extends CI_Controller_Rest { public function __construct() { parent::__construct(); } public function index() {} public function get() {} public function head() {} public function post() {} public function put() {} public function delete() {} }
我该怎么办?
如果一个类有一个或多个抽象函数,那么
it MUST be declared as an abstract class:
abstract class CI_Controller_Rest extends CI_Controller { public function __construct() { parent::__construct(); } abstract public function index(); abstract public function get(); abstract public function head(); abstract public function post(); abstract public function put(); abstract public function delete(); }