Quiz 13/27: Answer the following question

  • Suggested by FredBouchery
  • Created on 2020-09-28
  • Difficulty: expert

What will be displayed with PHP 8.0? 🤔

PHP Quiz n°13

Select your answer: 🧐

✅ { answer }: correct!

❌ { answer }: Wrong answer!

PHP 8 can now return "static". Prior to this version it returned a fatal error "unexpected static". In addition, you can use "::class" in a dynamic context (that was not allowed before). The right answer was "A".
▶  Click here to run this code on 3v4l.org


  • ✅ A: string(1) "B" - 53.3%
  • B: Fatal error: Declaration of B::foo(): B must be compatible with A::foo(): A - 10%
  • C: Parse error: syntax error, unexpected 'static' - 16.7%
  • D: Fatal error: Cannot use ::class with dynamic class name - 20%
▶  Click here to see the Twitter poll
Click here to see output differences between PHP versions

Prior to this version you get the following error: 'PHP Parse error: syntax error, unexpected 'static' (T_STATIC) on line 5'

Going further... 🤓

Want More? 🤔

New random question ⏩