Bird
0
0

Which of the following is the correct syntax to define a controller method in Laravel?

easy📝 Syntax Q3 of 15
Laravel - Controllers
Which of the following is the correct syntax to define a controller method in Laravel?
Ashow() { echo 'page'; }
Bfunction show() => return view('page');
Cpublic function show() { return view('page'); }
Ddef show(): return view('page')
Step-by-Step Solution
Solution:
  1. Step 1: Recall Laravel controller method syntax

    Laravel uses PHP syntax with public functions inside controller classes.
  2. Step 2: Identify correct PHP function syntax

    The correct syntax uses 'public function methodName() { ... }'.
  3. Final Answer:

    public function show() { return view('page'); } -> Option C
  4. Quick Check:

    Controller method syntax = public function [OK]
Quick Trick: Laravel controller methods use public function syntax [OK]
Common Mistakes:
  • Using arrow functions or Python syntax
  • Omitting 'public' keyword
  • Using JavaScript or other language syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes