Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
Laravel - Routing
What will be the output of this code?
Route::get('/home', fn() => 'Welcome')->name('home');
echo route('home');
AError: route not found
Bhttp://localhost/home
Chome
D/home
Step-by-Step Solution
Solution:
  1. Step 1: Understand route() helper output

    route('home') returns the full URL including domain for the named route.
  2. Step 2: Confirm echo output

    Echoing route('home') prints the full URL like 'http://localhost/home'.
  3. Final Answer:

    http://localhost/home -> Option B
  4. Quick Check:

    route() returns full URL [OK]
Quick Trick: route() returns the full URL for named routes [OK]
Common Mistakes:
  • Expecting only path without domain
  • Confusing route() with url() helper
  • Assuming route() returns route name string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes