親クラスを継承した子クラスがあるとき、例えば次のような時
class Client {
private $window_size = null;
private $driver = null;
public function __construct() {
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::chrome();
$options = new ChromeOptions();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$this->driver = RemoteWebDriver::create($host, $capabilities);
$this->driver->manage()->window()->setSize(new WebDriverDimension($this->width,$this->height));
}
}
class iphone extends phone {
public $width = 400;
public $height = 852;
public function __construct() {
$config = $this->getConfig();
$driver->get($config['url_login']);
}
}
とし、別のファイルで、
$mobile = new iphone();
と書く時、親元のphoneクラスのコンストラクタは実行されません。 なので以下のように子クラスのコンストラクタを書き直す必要があります。
public function __construct() {
parent::__construct();
$config = $this->getConfig();
$driver->get($config['url_login']);
}


