PHP Variables
- What will be the output of the following PHP code ?
<?php
$Fiv$e = 5;
$Si$x = 6;
$Seve$n = 7;
$Eigh$t = 8;
echo "$Fiv$e / $Si$x + $Seve$n / $Eigh$t";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
You can not use the $ in between the variable name.
- What will be the output of the following PHP code ?
<?php
$Fiv-e = 5;
$Si-x = 6;
$Seve-n = 7;
$Eigh-t = 8;
echo "$Fiv-e / $Si-x + $Seve-n / $Eigh-t";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
You can't use - in a variable name.
- What will be the output of the following PHP code ?
<?php
$Fiv_e = 5;
$Si_x = 6;
$Seve_n = 7;
$Eigh_t = 8;
echo "$Fiv_e / $Si_x + $Seve_n / $Eigh_t";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
You can use _ in a variable name.
- What will be the output of the following PHP code ?
<?php
echo $Yellow;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
There will no output returned as the variable $Yellow does not hold any value.
- What will be the output of the following PHP code ?
<?php
Five = 5;
Six = 6;
Seven = 7;
Eight = 8;
echo "Five / Six + Seven / Eight";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Variables should start with a $ symbol, since Five, Six, Seven, Eight don’t begin with $ symbol we’ll get an error.