Challenge - 5 Problems
Blade Echo Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Blade template?
Consider the following Blade template snippet:
If the variable
<p>Hello, {{ $name }}!</p>If the variable
$name is set to "Alice", what will be rendered in the browser?Laravel
<p>Hello, {{ $name }}!</p>Attempts:
2 left
💡 Hint
Remember that {{ }} in Blade templates outputs the value of the variable.
✗ Incorrect
The Blade syntax {{ $name }} outputs the value of the variable $name, which is 'Alice'. So the rendered HTML will be
Hello, Alice!
.📝 Syntax
intermediate2:00remaining
Which Blade syntax correctly escapes HTML?
Given the variable
$content contains the string <script>alert('Hi')</script>, which Blade syntax will safely display the string as text without running the script?Attempts:
2 left
💡 Hint
Blade's {{ }} syntax escapes HTML by default.
✗ Incorrect
Using {{ $content }} escapes HTML tags, so the script tags will be shown as text, preventing script execution. {!! $content !!} outputs raw HTML, which is unsafe here.
🔧 Debug
advanced2:00remaining
Why does this Blade template show raw PHP code instead of output?
This Blade template code:
renders as:
What is the most likely cause?
<p>User: {{ $user->name }}</p>renders as:
<p>User: {{ $user->name }}</p>What is the most likely cause?
Laravel
<p>User: {{ $user->name }}</p>Attempts:
2 left
💡 Hint
Blade templates must have the correct file extension to be compiled.
✗ Incorrect
If the file is not named with .blade.php extension, Laravel will not compile Blade syntax and will output it as plain text.
❓ state_output
advanced2:00remaining
What is the output when a variable is not set in Blade?
Given this Blade snippet:
and the variable
<p>Status: {{ $status }}</p>and the variable
$status is not passed to the view, what will be the rendered output?Laravel
<p>Status: {{ $status }}</p>Attempts:
2 left
💡 Hint
Blade treats undefined variables as empty strings when echoing.
✗ Incorrect
Blade outputs an empty string for undefined variables inside {{ }}, so the output is
Status:
without error.🧠 Conceptual
expert2:00remaining
Which Blade syntax prevents XSS by escaping output?
You want to display user input safely in a Blade template to prevent Cross-Site Scripting (XSS). Which syntax should you use?
Attempts:
2 left
💡 Hint
Blade's double curly braces escape HTML by default.
✗ Incorrect
Using {{ $userInput }} escapes HTML special characters, preventing scripts from running. {!! !!} outputs raw HTML, which is unsafe for user input.