调用父类构造函数

类 / 构造函数

<?php

class Man {
    public $name = "";

    function __construct(string $name) {
        $this->name = $name;
    }
}

class Employee extends Man {
    public $position = "";

    function __construct(string $name, string $position) { 
        parent::__construct($name);
        $this->position = $position;
    }
}

$employee = new Employee("Max", "booker");

echo $employee->name, "\n", $employee->position;