我有以下列出的课程
1. Software_Base
2. User Login
3. Basic Function
4. User Logout
我想要做的是我需要在另一个子类中访问子类方法。但与 extends
无关我的课程扩展如下所示
`
class base_class {
public function __construct(){
$this->init_class();
}
public function init_class(){
$this->user_login = new user_login;
$this->base_functions = new base_functions;
}
public function value_from_Base_class(){
return 'Value From Base Class';
}
}
class user_login extends base_class {
public function __construct(){
var_dump($this->value_from_Base_class()); # Works :)
}
public function value_from_user_login_class(){
return 'Value From User Login Class';
}
}
class user_logout extends user_login {
public function __construct(){
var_dump($this->value_from_Base_class()); # Works :)
var_dump($this->value_from_user_login_class()); # Works :)
}
}
class base_functions extends base_class{
public function __construct(){
var_dump($this->value_from_Base_class()); # Not Works :(
var_dump($this->value_from_user_login_class()); # Not Works :(
}
}
`
答案 0 :(得分:1)
在构建$return_value = array_filter($info, function($x) use ($mode) { return (in_array($x["name"], $mode));});
时注入<span onclick='setTimeout(start_timer_j(this, event), 0);'></span>
function start_timer_j(obj, event) {
var el = $(obj);
var count = 1000;
var counter = setInterval(timer, 100);
function timer(e) {
el.text('k');
count -=1;
}
el.text('k');
}
实例:
user_login
base_functions
中对class base_functions extends base_class{
public function __construct($user_login){
var_dump($this->value_from_Base_class());
var_dump($user_login->value_from_user_login_class());
}
}
$f = new base_functions(new user_login());
的调用无论如何都应该有用。