0
0
PHPprogramming~10 mins

How PHP executes on the server - Interactive Practice

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

Complete the code to start a PHP script.

PHP
<?php ?>
Drag options to blanks, or click blank then click option'
Astart
Becho
Cphp
Dscript
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'echo' or 'start' instead of the PHP opening tag.
Forgetting to open the PHP tag.
2fill in blank
medium

Complete the code to output text to the browser.

PHP
<?php echo [1]; ?>
Drag options to blanks, or click blank then click option'
A'Hello World'
B"Hello World"
CHello World
DHello
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the text.
Using incomplete quotes.
3fill in blank
hard

Fix the error in the PHP code to correctly end the statement.

PHP
<?php echo 'Hello'[1] ?>
Drag options to blanks, or click blank then click option'
A.
B;
C:
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using a period or colon instead of a semicolon.
Forgetting to end the statement.
4fill in blank
hard

Fill both blanks to create a PHP variable and assign a value.

PHP
<?php [1] = [2]; ?>
Drag options to blanks, or click blank then click option'
A$name
B'John'
CJohn
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Not using $ before variable name.
Assigning string without quotes.
5fill in blank
hard

Fill all three blanks to create an associative array and access a value.

PHP
<?php $person = array([1] => [2]); echo $person[[3]]; ?>
Drag options to blanks, or click blank then click option'
A'name'
B'John'
D'age'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around keys or values.
Using wrong key to access array.