ExamVeda
Login
Home
51
What will be the output of the following PHP code ?
<?php
one = 1;
two = 2;
three = 3;
four = 4;
echo "one / two + three / four";
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
Variables should start with a $ symbol, since one, two, three, four don’t begin with $ symbol we’ll get an error.
52
What will be the output of the following PHP code ?
<?php
$on$e = 1;
$tw$o = 2;
$thre$e = 3;
$fou$r = 4;
echo "$on$e / $tw$o + $thre$e / $fou$r"; 
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
You can not use the $ in between the variable name.
53
What will be the output of the following PHP code ?
<?php
$on_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
echo $on_e / $tw_o + $thre_e / $fou_r; 
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
You can use _ in a variable name.
54
What will be the output of the following PHP code ?
<?php
$On_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
echo $on_e / $tw_o + $thre_e / $fou_r;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Since the variable initialised is $On_e and the variable in the echo statement is $on_e the echo statement treats $on_e as 0;
55
What will be the output of the following PHP code ?
<?php
echo $red;
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
There will no output returned as the variable $red does not hold any value.
56
What will be the output of the following PHP code ?
<?php
$four4 = 4;
$three3 = 3;
$two2 = 2;
echo $four4 + $three3 / $two2 - 1;
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
You can use numbers in a variable name.
57
What will be the output of the following PHP code ?
<?php
$4four = 4;
$3three = 3;
$2two = 2;
echo $4four + $3three / $2two - 1;
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
A variable name can not start with a numeric value.
58
What will be the output of the following PHP code ?
<?php
int $one = 1;
echo "$one";
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
Unlike other programming languages there are no data types in PHP.
59
What will be the output of the following PHP code ?
<?php
var $one = 1;
var $two = 2;
echo $one / $two * $one / $two * $two;
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
You can not use var before a variable name.
60
What will be the output of the following PHP code ?
<?php
$hello = "Hello World";
$bye = "Bye";
echo $hello;"$bye";
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
Since there is a semi-colon in between $hello and $bye, the line ends at $hello. However $bye would have printed if a echo was present before “$bye”.