Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a variable named name with the value "John".
PHP
<?php [1]name = "John"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the dollar sign before the variable name.
Using other symbols like & or # instead of $.
✗ Incorrect
In PHP, all variables start with a dollar sign ($) followed by the variable name.
2fill in blank
mediumComplete the code to declare a variable named age with the value 25.
PHP
<?php [1]age = 25; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using symbols other than $ before the variable name.
Omitting the symbol entirely.
✗ Incorrect
Variables in PHP must start with a dollar sign ($) to be valid.
3fill in blank
hardFix the error in the variable declaration for city with value "Paris".
PHP
<?php [1]city = "Paris"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the dollar sign before the variable name.
Using the variable name without any symbol.
✗ Incorrect
The variable must start with a dollar sign ($) to be recognized in PHP.
4fill in blank
hardFill both blanks to declare two variables firstName and lastName with values "Alice" and "Smith".
PHP
<?php [1]firstName = "Alice"; [2]lastName = "Smith"; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different symbols for each variable.
Omitting the dollar sign on one or both variables.
✗ Incorrect
Both variables must start with a dollar sign ($) to be valid in PHP.
5fill in blank
hardFill all three blanks to declare variables city, country, and population with values "Rome", "Italy", and 2873000.
PHP
<?php [1]city = "Rome"; [2]country = "Italy"; [3]population = 2873000; ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different symbols for variables.
Forgetting the dollar sign before variable names.
✗ Incorrect
All variables must start with a dollar sign ($) in PHP.