Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 611 Bytes

0270.md

File metadata and controls

24 lines (20 loc) · 611 Bytes

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