Complete the code to declare a variable in PHP.
<?php $[1] = 10; echo $number; ?>
In PHP, variables start with a dollar sign followed by the variable name. Here, $number is the variable name.
Complete the code to output the value of the variable.
<?php $age = 25; echo [1]; ?>
To output the value of a variable in PHP, you use echo followed by the variable name with a dollar sign.
Fix the error in the code by completing the variable assignment.
<?php $[1] = 'Hello World'; echo $greeting; ?>
The variable name used in the assignment must match the one used in echo. Here, $greeting is correct.
Fill both blanks to create and output a variable holding a string.
<?php $[1] = [2]; echo $name; ?>
The variable $name is assigned the string value "John". Strings must be in quotes in PHP.
Fill all three blanks to declare, assign, and output a variable with a number.
<?php $[1] = [2]; echo $[3]; ?>
The variable $score is assigned the number 100 and then output with echo. The variable name must be consistent.