Complete the code to declare an interface named Logger.
<?php
interface [1] {
public function log(string $msg);
}
?>The keyword interface is followed by the interface name. Here, the interface is named Logger.
Complete the code to declare an abstract class named Vehicle.
<?php abstract class [1] { abstract public function startEngine(); } ?>
The keyword abstract class is followed by the class name. Here, the abstract class is named Vehicle.
Fix the error in the trait declaration by completing the code.
<?php trait [1] { public function sayHello() { echo "Hello!"; } } ?>
The keyword trait is followed by the trait name. Here, the trait is named GreetingTrait.
Fill both blanks to implement the Logger interface and use the GreetingTrait in the class.
<?php class User implements [1] { use [2]; public function log(string $msg) { echo $msg; } } ?>
The class User implements the Logger interface and uses the GreetingTrait trait to add behavior.
Fill all three blanks to declare an abstract class with an abstract method and use a trait inside it.
<?php abstract class [1] { use [2]; abstract public function [3](); } ?>
The abstract class Vehicle uses the trait GreetingTrait and declares an abstract method startEngine.