Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start a PHP script.
PHP
<?php ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'echo' or 'start' instead of the PHP opening tag.
Forgetting to open the PHP tag.
✗ Incorrect
PHP scripts start with the
2fill in blank
mediumComplete the code to output text to the browser.
PHP
<?php echo [1]; ?> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the text.
Using incomplete quotes.
✗ Incorrect
Text output in PHP must be inside quotes to be treated as a string.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a period or colon instead of a semicolon.
Forgetting to end the statement.
✗ Incorrect
Each PHP statement must end with a semicolon ; to separate it from the next.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using $ before variable name.
Assigning string without quotes.
✗ Incorrect
Variables in PHP start with $ and strings need quotes.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around keys or values.
Using wrong key to access array.
✗ Incorrect
Associative arrays use key => value pairs and keys are accessed with quotes.