如何用非静态方法覆盖静态方法?
代码
class Env {
static protected $vars = [
];
static public function get_env_var($var){
return self::$vars[$var];
}
static public function set_env_var($var, $value){
self::$vars[$var] = $value;
}
}
class Test extends Env {
private $env_vars = [];
public function __construct(){
$this->env_vars = self::$vars;
}
public function get_env_var($var){
return $this->env_vars[$var];
}
public function set_env_var($var, $value){
$this->env_vars[$var] = $value;
}
}
$Test = new Test();
错误
Cannot make static method Env::get_env_var() non static in class Test in