Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the variable inside double quotes using interpolation.
PHP
<?php $name = "Alice"; echo "Hello, [1]!"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the $ sign before the variable name.
Using single quotes which do not interpolate variables.
✗ Incorrect
In PHP, variables inside double quotes are interpolated when prefixed with $. So "$name" prints the variable's value.
2fill in blank
mediumComplete the code to include the variable inside a sentence using double quotes and interpolation.
PHP
<?php $age = 25; echo "I am [1] years old."; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which do not interpolate variables.
Omitting the $ sign before the variable.
✗ Incorrect
Using $age inside double quotes prints the value of the variable age.
3fill in blank
hardFix the error in the code to correctly interpolate the variable inside double quotes.
PHP
<?php $city = "Paris"; echo "Welcome to [1]!"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without $ inside double quotes.
Using single quotes which do not interpolate variables.
✗ Incorrect
Variables inside double quotes must have the $ sign to be interpolated correctly.
4fill in blank
hardFill both blanks to correctly interpolate the variable and add a suffix inside double quotes.
PHP
<?php $score = 90; echo "Your score is [1][2]."; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the $ sign before the variable.
Using % instead of ' points' as suffix.
✗ Incorrect
Use $score to interpolate the variable and add ' points' as a suffix inside the string.
5fill in blank
hardFill all three blanks to create a sentence with two interpolated variables and a connector inside double quotes.
PHP
<?php $firstName = "John"; $lastName = "Doe"; echo "My name is [1] [2] [3]."; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without $ sign.
Using 'or' instead of 'and' as connector.
✗ Incorrect
Use $firstName and $lastName to interpolate the variables and 'and' as the connector word.