0
0
PHPprogramming~10 mins

Why output functions matter in PHP - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the message to the screen.

PHP
<?php
[1]("Hello, world!");
?>
Drag options to blanks, or click blank then click option'
Aecho
Bvar_dump
Cprint_r
Dprintf
Attempts:
3 left
💡 Hint
Common Mistakes
Using var_dump which shows extra information.
Using print_r which is for arrays and objects.
2fill in blank
medium

Complete the code to output the variable content.

PHP
<?php
$message = "Welcome!";
[1]($message);
?>
Drag options to blanks, or click blank then click option'
Aprint
Becho
Cvar_dump
Dprintf
Attempts:
3 left
💡 Hint
Common Mistakes
Using var_dump which adds type info.
Using printf without format specifiers.
3fill in blank
hard

Fix 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'
Aprint_r
Bprintf
Cvar_dump
Decho
Attempts:
3 left
💡 Hint
Common Mistakes
Using print_r which is for arrays and objects.
Using var_dump which outputs extra info.
4fill in blank
hard

Fill 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'
Aprintf
B$score
C10
Decho
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo with format specifiers which doesn't work.
Passing a wrong variable or value.
5fill in blank
hard

Fill 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'
Aprint_r
B$fruits
Cvar_dump
Decho
Attempts:
3 left
💡 Hint
Common Mistakes
Using echo which cannot print arrays.
Using var_dump which outputs extra type information.