Bird
0
0

Which of these is the correct Laravel syntax to define a route that returns 'Welcome' when visiting '/welcome'?

easy📝 Syntax Q3 of 15
Laravel - Routing
Which of these is the correct Laravel syntax to define a route that returns 'Welcome' when visiting '/welcome'?
ARoute::get('/welcome', function () { return 'Welcome'; });
BRoute::post('/welcome', 'WelcomeController@index');
CRoute::put('/welcome', function () { echo 'Welcome'; });
DRoute::delete('/welcome', function () { return 'Welcome'; });
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct HTTP method for viewing a page

    GET is used to retrieve or view pages, so Route::get is correct.
  2. Step 2: Check the syntax for returning a string in a closure

    The closure returns 'Welcome' correctly with return statement and semicolon.
  3. Final Answer:

    Route::get('/welcome', function () { return 'Welcome'; }); -> Option A
  4. Quick Check:

    Correct route syntax = Route::get('/welcome', function () { return 'Welcome'; }); [OK]
Quick Trick: Use Route::get for page views [OK]
Common Mistakes:
  • Using wrong HTTP method for simple page
  • Using echo instead of return in closure
  • Missing semicolon at end

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes