Bird
0
0

Identify the error in this route definition: Route::get('/order/{id}', function) { return $id; });

medium📝 Debug Q6 of 15
Laravel - Routing
Identify the error in this route definition: Route::get('/order/{id}', function) { return $id; });
AMissing semicolon after route definition
BMissing parameter in function parentheses
CIncorrect route URL syntax
DUsing parentheses instead of curly braces for parameter
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameter list

    The function is declared as 'function)' without parameters, but it should accept $id.
  2. Step 2: Confirm correct syntax

    The route parameter {id} must be matched by a function parameter $id to access it.
  3. Final Answer:

    Missing parameter in function parentheses -> Option B
  4. Quick Check:

    Function must accept route parameters [OK]
Quick Trick: Function must list all route parameters [OK]
Common Mistakes:
  • Omitting function parameters
  • Wrong URL syntax
  • Forgetting semicolon
  • Using wrong brackets for parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes