Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 715 Bytes

0787.md

File metadata and controls

28 lines (22 loc) · 715 Bytes

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