Bird
0
0

Given this controller method in Laravel:

medium📝 component behavior Q13 of 15
Laravel - Controllers
Given this controller method in Laravel:
public function greet() { return 'Hello, Laravel!'; }

What will be the output when this method is called by a route?
AThe view named 'Hello, Laravel!'
BA blank page
CAn error because return type is missing
DHello, Laravel!
Step-by-Step Solution
Solution:
  1. Step 1: Understand what the method returns

    The method returns a plain string 'Hello, Laravel!'.
  2. Step 2: Know Laravel's response behavior

    Returning a string from a controller sends that string as the HTTP response body.
  3. Final Answer:

    Hello, Laravel! -> Option D
  4. Quick Check:

    Return string from controller = output string [OK]
Quick Trick: Return strings directly to send text response [OK]
Common Mistakes:
  • Expecting a view instead of string
  • Thinking missing return type causes error
  • Assuming blank page means success

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes