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?
@php
  $value = 10;
  if ($value > 5) {
    echo 'High';
  }
ACannot use if statements inside @php
BMissing closing @endphp directive
CEcho should be replaced with {{ }}
DVariable $value is not defined
Step-by-Step Solution
Solution:
  1. Step 1: Check for proper @php block closure

    The code starts with @php but does not have a closing @endphp.
  2. Step 2: Validate other syntax

    If statements and echo are valid inside @php. Variable is defined.
  3. Final Answer:

    Missing closing @endphp directive -> Option B
  4. Quick Check:

    Always close @php blocks with @endphp [OK]
Quick Trick: Never forget to close @php with @endphp [OK]
Common Mistakes:
  • Leaving @php block open
  • Thinking echo is invalid inside @php
  • Confusing Blade echo with PHP echo

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes