<<< Previous question <<< Question ID#0270.md >>> Next question >>>
What is the result of the following code?
$x = new class extends \stdClass {
function getName() {
return 'PHP';
}
};
echo $x->getName();
- A) PHP
- B) A fatal error because \stdClass is a special class that cannot be used directly
- C) A warning saying than all anonymous class must be declared public
- D) A fatal error because anonymous classes cannot inherit from other classes
Answer
Answer: A