我想澄清一下我遇到的问题
我有一个基础DataBase类,将由许多其他类继承.构造函数如下所示:
public function __construct ($table)
{
$this->table = $table;
$this->db = new Database();
$this->db->connect();
}
Run Code Online (Sandbox Code Playgroud)
我会从这个构造函数中调用来自以下的子代:
public function __construct ($something)
{
parent::__construct("planets_games");
}
Run Code Online (Sandbox Code Playgroud)
我的问题是php不允许我在没有$ something参数的情况下创建孩子的构造函数,我得到以下内容:
Fatal error: Declaration of planetsGames::__construct() must be compatible with that of IScaffold::__construct()
Run Code Online (Sandbox Code Playgroud)
我目前通过实例化这样的对象来绕过这个:
$pg = new planetsGames('uselessStringHereThatHasNoUtilityAtAll');
Run Code Online (Sandbox Code Playgroud)
我想我在基本的PHP知识中缺少一些非常重要的东西
非常感谢您的帮助