Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the text "Hello, World!".
PHP
<?php [1] "Hello, World!"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'write' which is not a PHP statement.
Forgetting the semicolon at the end.
Using 'printf' without format specifiers.
✗ Incorrect
The echo statement is used in PHP to output text to the screen.
2fill in blank
mediumComplete the code to print the value of the variable $name.
PHP
<?php $name = "Alice"; [1] $name; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to use 'write' or 'display' which are not PHP commands.
Putting quotes around the variable name which would print the variable name literally.
✗ Incorrect
echo can print variables directly in PHP.
3fill in blank
hardFix the error in the code to correctly print "Age: 30".
PHP
<?php $age = 30; [1] "Age: " . $age; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'printline' which does not exist in PHP.
Forgetting to concatenate strings properly.
✗ Incorrect
echo is the correct statement to print concatenated strings and variables.
4fill in blank
hardFill both blanks to print the sentence "Hello, John!" using variable $name.
PHP
<?php $name = "John"; [1] "Hello, " . [2] . "!"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name which prints it literally.
Using 'print' instead of 'echo' (both work but only one is correct here).
✗ Incorrect
echo prints the concatenated string and variable $name holds the name.
5fill in blank
hardFill both blanks to print the sentence "The total is 100;" using variable $total.
PHP
<?php $total = 100; [1] "The total is " . [2] . ; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the semicolon at the end.
Using 'print' instead of 'echo' (both work but only one is correct here).
Putting quotes around the variable name.
✗ Incorrect
echo prints the concatenated string and variable $total. The semicolon ends the statement.