Bird
0
0

Which Blade directive is used to check if a variable is true and display content accordingly?

easy📝 Conceptual Q2 of 15
Laravel - Views and Blade Templates
Which Blade directive is used to check if a variable is true and display content accordingly?
A@foreach
B@if
C@for
D@while
Step-by-Step Solution
Solution:
  1. Step 1: Identify the conditional directive

    @if is the Blade directive used to check conditions and display content if true.
  2. Step 2: Differentiate from loops

    @foreach, @for, and @while are looping directives, not for simple condition checks.
  3. Final Answer:

    @if -> Option B
  4. Quick Check:

    @if = Conditional display [OK]
Quick Trick: Use @if for conditions, not loops [OK]
Common Mistakes:
  • Using @foreach for conditions
  • Confusing @for with @if
  • Trying to use @while in Blade without PHP logic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes