Bird
0
0

What is wrong with this Blade code?

medium📝 Debug Q7 of 15
Laravel - Views and Blade Templates
What is wrong with this Blade code?
@foreach($products as $product)
  {{ $product->name }
@endforeach
ANo error, code is valid
BIncorrect loop variable name
C@foreach directive is misspelled
DMissing closing curly brace in variable output
Step-by-Step Solution
Solution:
  1. Step 1: Check variable output syntax

    Blade variables must be enclosed in double curly braces {{ }} fully.
  2. Step 2: Identify missing brace

    The code has only one closing brace, missing the second one.
  3. Final Answer:

    Missing closing curly brace in variable output -> Option D
  4. Quick Check:

    Variable output needs {{ and }} [OK]
Quick Trick: Always close Blade variables with double curly braces {{ }} [OK]
Common Mistakes:
  • Using single curly brace
  • Misspelling @foreach
  • Wrong loop variable name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes