Bird
0
0

Find the problem in this route:

medium📝 Debug Q7 of 15
Laravel - Routing
Find the problem in this route:
Route::get('/post/{id}', function () { return 'Post ID: ' . $id; });
AThe HTTP method should be POST
BThe function does not accept the $id parameter
CThe route URL is missing curly braces
DThe return statement should use echo
Step-by-Step Solution
Solution:
  1. Step 1: Check route parameter usage

    The URL has {id} parameter, so the function must accept $id as argument.
  2. Step 2: Verify function parameters

    The function has empty parentheses, so $id is missing and causes error.
  3. Final Answer:

    The function does not accept the $id parameter -> Option B
  4. Quick Check:

    Route parameter must be function argument [OK]
Quick Trick: Match route params with function args [OK]
Common Mistakes:
  • Forgetting to add parameter to function
  • Changing HTTP method unnecessarily
  • Using echo instead of return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes