Bird
0
0

How do you correctly declare an interface named Vehicle in PHP?

easy📝 Syntax Q3 of 15
PHP - Interfaces and Traits
How do you correctly declare an interface named Vehicle in PHP?
Ainterface Vehicle[] { public function move(); }
Bclass Vehicle { public function move(); }
Cinterface Vehicle() { function move(); }
Dinterface Vehicle { public function move(); }
Step-by-Step Solution
Solution:
  1. Step 1: Syntax for interface

    Use the keyword interface followed by the name and curly braces.
  2. Step 2: Method declaration

    Methods inside interfaces must be declared without implementation and with visibility (usually public).
  3. Final Answer:

    interface Vehicle { public function move(); } -> Option D
  4. Quick Check:

    Interfaces use 'interface' keyword and method signatures only. [OK]
Quick Trick: Use 'interface' keyword and declare methods without body. [OK]
Common Mistakes:
  • Using 'class' instead of 'interface'
  • Adding parentheses after interface name
  • Using square brackets in declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes