Bird
0
0

Identify the error in this Blade template snippet:

medium📝 Debug Q14 of 15
Laravel - Views and Blade Templates
Identify the error in this Blade template snippet:
@foreach($items as $item)
  <p>{{ $item }}</p>
@endforeachd
AThe variable $item should be escaped with triple braces
BThe closing directive should be <code>@endforeach</code>, not <code>@endforeachd</code>
CThe loop variable should be $items, not $item
DMissing semicolon after {{ $item }}
Step-by-Step Solution
Solution:
  1. Step 1: Check foreach directive syntax

    The correct closing directive for a foreach loop is @endforeach.
  2. Step 2: Identify typo in closing directive

    The snippet uses @endforeachd which is invalid and causes a syntax error.
  3. Final Answer:

    The closing directive should be @endforeach, not @endforeachd -> Option B
  4. Quick Check:

    Correct directive spelling = @endforeach [OK]
Quick Trick: Check directive spelling carefully, no extra letters [OK]
Common Mistakes:
  • Adding extra letters to Blade directives
  • Thinking variables need semicolons in Blade
  • Confusing loop variable names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes