Bird
0
0

Which of the following is the correct Laravel syntax to define a route for a GET request to '/home'?

easy📝 Syntax Q12 of 15
Laravel - Routing
Which of the following is the correct Laravel syntax to define a route for a GET request to '/home'?
ARoute::post('/home', function () { return 'Home'; });
BRoute::delete('/home', function () { return 'Home'; });
CRoute::put('/home', function () { return 'Home'; });
DRoute::get('/home', function () { return 'Home'; });
Step-by-Step Solution
Solution:
  1. Step 1: Identify HTTP method for route

    GET requests retrieve data or pages, so Route::get is used for '/home'.
  2. Step 2: Check syntax correctness

    Route::get('/home', function () { return 'Home'; }); uses Route::get with a closure returning 'Home', which is correct syntax.
  3. Final Answer:

    Route::get('/home', function () { return 'Home'; }); -> Option D
  4. Quick Check:

    GET route syntax = Route::get('/home', function () { return 'Home'; }); [OK]
Quick Trick: Use Route::get for GET URLs, not post/put/delete [OK]
Common Mistakes:
  • Using Route::post for GET requests
  • Mixing HTTP methods and routes
  • Incorrect closure syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes