<<< Previous question <<< Question ID#0787.md >>> Next question >>>
What is displayed when the following code is executed?
abstract class A {
abstract public function f();
}
(new anonymousclass extends A {
public function f() {
echo 'Hello World';
}
})->f();
- A) A parse error because the "anonymousclass" keyword does not exist in PHP;
- B) A parse error because anonymous classes cannot extends abstract class;
- C) A runtime error because you must first store anonymous class in a variable before calling methods on it;
- D) Hello World
Answer
Answer: A