PHP

PHP

Variables has 36 Questions

What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. $z = "$x + $y";
  5. echo "$z";
  6. ?>

15
10 + 5
$z
$x + $y
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 4;
  3. $y = 3;
  4. $z = 1;
  5. echo "$x = $x + $y + $z";
  6. ?>

4 = 4 + 3 + 1
8
8 = 4 + 3 +1
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 4;
  3. $y = 3
  4. $z = 1;
  5. $z = $z + $x + $y;
  6. echo "$z";
  7. ?>

$z
15
8
1
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 3.3;
  3. $y = 2;
  4. echo $x % $y;
  5. ?>

0
1
2
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 4;
  4. $z = 3;
  5. echo $x % $y % $z;
  6. ?>

0
1
2
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 4;
  4. $z = 3;
  5. echo ($x % ($y) + $z);
  6. ?>

5
3
0
1
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 30;
  3. $y = 20;
  4. $z = 10;
  5. echo $x + $y - $z / ($z - $y);
  6. ?>

41
-4
-5
51
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 4;
  3. $y = -3;
  4. $z = 11;
  5. echo 4 + $y * $z / $x;
  6. ?>

4.25
3.25
-3.25
-4.25
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 3.5;
  3. $y = 2;
  4. $z = 2;
  5. echo $x / $y / $z;
  6. ?>

1.75
0.875
3.5
Error
What will be the output of the following PHP code ?
  1. <?php
  2. one = 1;
  3. two = 2;
  4. three = 3;
  5. four = 4;
  6. echo "one / two + three / four";
  7. ?>

0.75
0.05
1.25
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $on$e = 1;
  3. $tw$o = 2;
  4. $thre$e = 3;
  5. $fou$r = 4;
  6. echo "$on$e / $tw$o + $thre$e / $fou$r"; 
  7. ?>

0.75
0.05
1.25
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $on_e = 1;
  3. $tw_o = 2;
  4. $thre_e = 3;
  5. $fou_r = 4;
  6. echo $on_e / $tw_o + $thre_e / $fou_r; 
  7. ?>

0.75
0.05
1.25
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $On_e = 1;
  3. $tw_o = 2;
  4. $thre_e = 3;
  5. $fou_r = 4;
  6. echo $on_e / $tw_o + $thre_e / $fou_r;
  7. ?>

0.75
0.05
1.25
Error
What will be the output of the following PHP code ?
  1. <?php
  2. echo $red;
  3. ?>

0
Nothing
True
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $four4 = 4;
  3. $three3 = 3;
  4. $two2 = 2;
  5. echo $four4 + $three3 / $two2 - 1;
  6. ?>

4.5
7
3.5
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $4four = 4;
  3. $3three = 3;
  4. $2two = 2;
  5. echo $4four + $3three / $2two - 1;
  6. ?>

4.5
7
3.5
Error
What will be the output of the following PHP code ?
  1. <?php
  2. var $one = 1;
  3. var $two = 2;
  4. echo $one / $two * $one / $two * $two;
  5. ?>

1
0
0.5
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $hello = "Hello World";
  3. $bye = "Bye";
  4. echo $hello;"$bye";
  5. ?>

Hello World
Bye
Hello worldBye
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x;
  3. echo "$x";
  4. ?>

0
1
Nothing
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. {
  4.     echo "$x";
  5. }
  6. ?>

0
5
Nothing
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. function fun()
  4. {
  5.     echo "$x";
  6. }
  7. fun();
  8. ?>

0
5
Nothing
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. function fun()
  4. {
  5.     $x = 10;
  6.     echo "$x";
  7. }
  8. fun();
  9. echo "$x";
  10. ?>

0
105
510
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 4;
  3. $y = 3;
  4. function fun($x = 3, $y = 4)
  5. {
  6.     $z = $x+$y/$y+$x;
  7.     echo "$z";
  8. } 
  9. echo $x;
  10. echo $y;
  11. echo $z; 
  12. fun($x, $y);
  13. ?>

43
943
349
439
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 4;
  3. $y = 3;
  4. function fun($x, $y)
  5. {
  6.     $z = $x + $y / $y + $x;
  7.     echo "$z";
  8. }
  9. echo $x;
  10. echo $y;
  11. echo $z; 
  12. fun(3, 4);
  13. ?>

437
439
349
347
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 3, 4, 5, 6;
  3. echo "$x";
  4. ?>

3
4
6
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. $b = 4;
  4. $c = fun(10,4);
  5. function fun($a,$b)
  6. {
  7.     $b = 3;
  8.     return $a - $b + $b - $a; 
  9. }
  10. echo $a;
  11. echo $b;
  12. echo $c;
  13. ?>

104
410
1400
4100
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. {
  4.     $x = 10;
  5.     echo "$x";
  6. }
  7. echo "$x";
  8. ?>

1010
105
510
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "$winner";
  3. $b = "/$looser";
  4. echo $a,$b;
  5. ?>

$winner/$looser
/$looser
/
$looser
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "$winner";
  3. $b = "\$looser";
  4. echo $a, $b;
  5. ?>

$winner\$looser
\$looser
\
$looser
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "$winner";
  3. $b = "\\$looser";
  4. echo $a, $b;
  5. ?>

$winner\\$looser
\\$looser
\
$looser
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. function fun()
  5. {
  6.     $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
  7. } 
  8. fun();
  9. echo $y;
  10. ?>

5
10
15
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. function fun()
  5. {
  6.     $y = $GLOBALS['x'] + $GLOBALS['y'];
  7. } 
  8. fun();
  9. echo $y;
  10. ?>

5
10
15
Error
What will be the output of the following PHP code ?
  1. <?php
  2. function fun()
  3. {
  4.     $x = 0;
  5.     echo $x;
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

012
123
000
111
What will be the output of the following PHP code ?
  1. <?php
  2. function fun()
  3. {
  4.     static $x = 0;
  5.     echo $x;
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

012
123
111
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x=0;
  3. function fun()
  4. {
  5.     echo $GLOBALS['x'];
  6.     $GLOBALS['x']++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

000
012
123
Error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 0;
  3. function fun()
  4. {
  5.     echo $GLOBALS['x'];
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

000
012
Nothing
Error