按php手册里的abstract代码没有问题,下面代码哪里错了?
<br />abstract class A{<br /> abstract public function b(); <br />}<br /><br />class B extends A{<br /> public function b(){<br /> print "ok";<br /> }<br />}<br /><br />$k = new B();<br />
$k没有调用b()方法,为什么会出现
按php手册里的abstract代码没有问题,上面代码哪里错了?
------解决思路----------------------没有错
class
B extends A{
public function
b(){
print "ok";
}
}
方法 b 是类 B 的构造函数,在实例化时自动执行,所以有 ok 被输出
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn