Games PHP Class Tree

Class Tree · Level 1 of 7

Who builds the object

Two children of Animal, each with its own constructor. Only one calls its parent.

<?phpclass Animal {    public function __construct() { echo "Animal built\n"; }}class Dog extends Animal {    public function __construct() { echo "Dog built\n"; }}class Cat extends Animal {    public function __construct() {        parent::__construct();        echo "Cat built\n";    }}new Dog();new Cat();

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…