0
0
PHPprogramming~10 mins

Variable declaration with dollar sign 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 declare a variable named name with the value "John".

PHP
<?php
[1]name = "John";
?>
Drag options to blanks, or click blank then click option'
A$
B&
C#
D%
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the dollar sign before the variable name.
Using other symbols like & or # instead of $.
2fill in blank
medium

Complete 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'
A&
B@
C#
D$
Attempts:
3 left
💡 Hint
Common Mistakes
Using symbols other than $ before the variable name.
Omitting the symbol entirely.
3fill in blank
hard

Fix 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'
Acity
B&
C$
D#
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the dollar sign before the variable name.
Using the variable name without any symbol.
4fill in blank
hard

Fill 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'
A$
B&
C#
D@
Attempts:
3 left
💡 Hint
Common Mistakes
Using different symbols for each variable.
Omitting the dollar sign on one or both variables.
5fill in blank
hard

Fill 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'
A&
B$
C#
D@
Attempts:
3 left
💡 Hint
Common Mistakes
Using different symbols for variables.
Forgetting the dollar sign before variable names.