Bird
0
0

Identify the error in this Laravel route:

medium📝 Debug Q14 of 15
Laravel - Routing
Identify the error in this Laravel route:
Route::get('/user', function { return 'User page'; });
AMissing parentheses after function keyword
BRoute URL should be '/users' not '/user'
CReturn statement cannot be used in routes
DRoute::get should be Route::post for pages
Step-by-Step Solution
Solution:
  1. Step 1: Check function syntax

    Anonymous functions require parentheses after 'function', even if empty.
  2. Step 2: Identify syntax error

    The code misses '()' after 'function', causing a syntax error.
  3. Final Answer:

    Missing parentheses after function keyword -> Option A
  4. Quick Check:

    Anonymous function needs () after function [OK]
Quick Trick: Always add () after function keyword in closures [OK]
Common Mistakes:
  • Omitting parentheses after function
  • Changing URL unnecessarily
  • Misunderstanding return usage in routes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes