Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start a raw PHP block in a Blade template.
Laravel
@[1] $message = 'Hello from PHP!'; @endphp
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @phpstart or @phpblock which are not valid Blade directives.
Forgetting the @ symbol before php.
✗ Incorrect
Use @php to start a raw PHP block in Blade templates.
2fill in blank
mediumComplete the code to end a raw PHP block in a Blade template.
Laravel
@php
$count = 5;
[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @phpend or @stopphp which are not valid Blade directives.
Forgetting to close the PHP block.
✗ Incorrect
Use @endphp to close a raw PHP block in Blade templates.
3fill in blank
hardFix the error in the Blade template to correctly embed raw PHP code.
Laravel
@php
echo 'Count is: ' . [1];
@endphp Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without $ inside PHP blocks.
Using function calls like count() when variable is intended.
✗ Incorrect
Inside raw PHP blocks, variables must have the $ sign to be valid PHP.
4fill in blank
hardFill both blanks to create a Blade template that sets a PHP variable and echoes it.
Laravel
@[1] $name = 'Laravel'; echo 'Welcome to ' . [2]; @endphp
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' without $ inside PHP.
Using invalid directive like @phpstart.
✗ Incorrect
Use @php to start the block and $name to echo the variable inside PHP.
5fill in blank
hardFill all three blanks to create a Blade template that declares two PHP variables and echoes their sum.
Laravel
@[1] $a = 10; $b = 20; echo [2] + [3]; @endphp
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without $ inside PHP.
Using invalid directive like @phpblock.
✗ Incorrect
Use @php to start the block and $a, $b to refer to the variables inside PHP.