Complete the code to declare a class that implements two interfaces.
<?php
interface A {}
interface B {}
class MyClass implements [1] {}
?>In PHP, to implement multiple interfaces, list them separated by commas.
Complete the code to define interface B with a method named 'bar'.
<?php
interface B {
public function [1]();
}
?>The interface B requires a method named 'bar'.
Fix the error in the class method implementation for interface A's method 'foo'.
<?php
interface A {
public function foo();
}
class MyClass implements A {
public function [1]() {
echo "Hello";
}
}
?>The class must implement the method 'foo' exactly as declared in interface A.
Fill both blanks to complete the class implementing interfaces A and B with required methods.
<?php
interface A {
public function foo();
}
interface B {
public function bar();
}
class MyClass implements A, B {
public function [1]() {
echo "foo method";
}
public function [2]() {
echo "bar method";
}
}
?>The class must implement both methods 'foo' and 'bar' as declared in interfaces A and B.
Fill all three blanks to create a class that implements interfaces A and B and calls both methods.
<?php
interface A {
public function foo();
}
interface B {
public function bar();
}
class MyClass implements A, B {
public function [1]() {
echo "foo called";
}
public function [2]() {
echo "bar called";
}
}
$obj = new MyClass();
$obj->[3]();
$obj->bar();
?>The class implements 'foo' and 'bar'. The object calls 'foo' and 'bar' methods.