Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the message to the screen.
PHP
<?php [1]("Hello, world!"); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using var_dump which shows extra information.
Using print_r which is for arrays and objects.
✗ Incorrect
The echo statement outputs the string directly to the screen.
2fill in blank
mediumComplete the code to output the variable content.
PHP
<?php $message = "Welcome!"; [1]($message); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using var_dump which adds type info.
Using printf without format specifiers.
✗ Incorrect
echo outputs the value of the variable as plain text.
3fill in blank
hardFix the error in the code to correctly output the number.
PHP
<?php $number = 10; [1]("Number: $number"); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using print_r which is for arrays and objects.
Using var_dump which outputs extra info.
✗ Incorrect
echo correctly outputs the string with the variable inside.
4fill in blank
hardFill both blanks to output the formatted string with a number.
PHP
<?php $score = 95; [1]("Your score is %d.", [2]); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo with format specifiers which doesn't work.
Passing a wrong variable or value.
✗ Incorrect
printf formats the string with the number passed as the second argument.
5fill in blank
hardFill the blanks to output the array content in a readable way.
PHP
<?php $fruits = ['apple', 'banana', 'cherry']; [1]([2]); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo which cannot print arrays.
Using var_dump which outputs extra type information.
✗ Incorrect
print_r outputs arrays in a readable format.