被这个问题debug了一个上午.
class boot {
static $table;
}
class customer extends boot {
public static function get_table() {
static::$table = 'customer';
}
}
class api extends boot {
static function get_table() {
static::$table = 'api_log_use';
call_user_func(['customer', 'get_table']);
var_dump(static::$table);
}
}
api::get_table();
当在api类中call customer类的时候。这个$table变量会被覆盖. 最终解决办法: 在每个类中独立定义$table这个变量
class boot {
static $table;
}
class customer extends boot {
static $table;
public static function get_table() {
static::$table = 'customer';
}
}
class api extends boot {
static $table;
static function get_table() {
static::$table = 'api_log_use';
call_user_func(['customer', 'get_table']);
var_dump(static::$table);
}
}
api::get_table();