我有一节课:
class test {
function __construct() {
print 'hello';
}
function func_one() {
print 'world';
}
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是有一个类扩展测试类.我说'有点',因为类需要能够运行测试类能够运行的任何函数,但是除非我要求它运行,否则不运行构造.我不想覆盖构造.任何人都知道如何实现这一目标?
class test {
function __construct() {
print 'hello';
}
function func_one() {
print 'world';
}
}
class test_2 extends test {
function __construct() {
if (i want to) {
parent::__construct();
}
}
}
Run Code Online (Sandbox Code Playgroud)