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($users as $user)
  

{{ $user->name }}

@endforeach @endforeach
AHTML tags not allowed inside Blade loops
BMissing @endforeach directive
CIncorrect variable name $user
DExtra @endforeach causing syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Count @foreach and @endforeach directives

    There is one @foreach but two @endforeach directives.
  2. Step 2: Identify the error caused by extra @endforeach

    Extra @endforeach causes a syntax error because it closes a non-existent loop.
  3. Final Answer:

    Extra @endforeach causing syntax error -> Option D
  4. Quick Check:

    Matching @foreach/@endforeach count is crucial [OK]
Quick Trick: Match each @foreach with one @endforeach [OK]
Common Mistakes:
  • Adding extra @endforeach
  • Forgetting to close loops
  • Misnaming variables inside loops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes