0
0
PHPprogramming~10 mins

Print statement in PHP - Interactive Code Practice

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

Complete the code to print the text "Hello, World!".

PHP
<?php
[1] "Hello, World!";
?>
Drag options to blanks, or click blank then click option'
Awrite
Bprint
Cprintf
Decho
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.
2fill in blank
medium

Complete 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'
Awrite
Bprintline
Cecho
Ddisplay
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.
3fill in blank
hard

Fix 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'
Aecho
Bprintline
Cwrite
Ddisplay
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'printline' which does not exist in PHP.
Forgetting to concatenate strings properly.
4fill in blank
hard

Fill 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'
Aecho
B$name
Cprint
D"name"
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).
5fill in blank
hard

Fill 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'
Aprint
B$total
C;
Decho
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.