PHP

PHP

Operators has 41 Questions
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. while ($i = 10)
  4. {   
  5.     print "hi";
  6. }
  7. print "hello";
  8. ?>

hello
infinite loop
hihello
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = "";
  3. while ($i = 10)
  4. {   
  5.     print "hi";
  6. }
  7. print "hello";
  8. ?>

hello
infinite loop
hihello
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. while ($i = 10)
  4. {   
  5.     print "hi";
  6. }
  7. print "hello";
  8. ?>

hello
infinite loop
hihello
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 5;
  3. while (--$i > 0)
  4. {   
  5.     $i++;
  6.     print $i;
  7.     print "hello";
  8. }
  9. ?>

4hello4hello4hello4hello4hello.....infinite
5hello5hello5hello5hello5hello.....infinite
no output
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 5;
  3. while (--$i > 0 && ++$i)
  4. {   
  5.     print $i;
  6. }
  7. ?>

5
555555555...infinitely
54321
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 5;
  3. while (--$i > 0 || ++$i)
  4. {   
  5.     print $i;
  6. }
  7. ?>

54321111111....infinitely
555555555...infinitely
54321
5
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. while(++$i || --$i)
  4. {   
  5.     print $i;
  6. }
  7. ?>

1234567891011121314....infinitely
01234567891011121314...infinitely
1
0
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. while (++$i && --$i)
  4. {   
  5.     print $i;
  6. }
  7. ?>

1234567891011121314....infinitely
01234567891011121314...infinitely
no output
error
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 2;
  3. while (++$i)
  4. {   
  5.     while ($i --> 0)
  6.         print $i;
  7. }
  8. ?>

210
10
no output
infinite loop
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 2;
  3. while (++$i)
  4. {   
  5.     while (--$i > 0)
  6.         print $i;
  7. }
  8. ?>

210
10
no output
infinite loop
What will be the output of the following PHP code ?
  1. <?php
  2. echo 5 * 9 / 3 + 9;
  3. ?>

24
3.7
3.85
0
What will be the output of the following PHP code ?
  1. <?php
  2. echo 5 * 9 / 3 + 9
  3. ?>

24
3.7
3.85
0
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. $j = 0;
  4. if ($i && ($j = $i + 10)) {
  5.     echo "true";
  6. }
  7. echo $j;
  8. ?>

10
0
true0
true10
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 10;
  3. $j = 0;
  4. if ($i || ($j = $i + 10)) {
  5.     echo "true";
  6. }
  7. echo $j;
  8. ?>

20
true0
0
true20
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 1;
  3. if ($i++ && ($i == 1))
  4.     printf("Yes\n$i");
  5. else
  6.     printf("No\n$i");
  7. ?>

No 2
Yes 1
Yes 2
No 1
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 1; $b = 3;
  3. $d = $a++ + ++$b;
  4. echo $d;
  5. ?>

5
4
3
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 1; $b = 1; $d = 1;
  3. print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;
  4. ?>

869
742
368
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10; $b = 10;
  3. if ($a = 5)
  4.     $b--;
  5. print $a;print $b--;
  6. ?>

58
59
109
108
What will be the output of the following PHP code ?
  1. <?php
  2. $i = 0;
  3. $x = $i++; $y = ++$i;
  4. print $x; print $y; 
  5. ?>

02
12
01
21
What will be the output of the following PHP code ?
  1. <?php
  2.  $a = 5; $b = -7; $c =0; 
  3.  $d = ++$a && ++$b || ++$c;
  4.  print $d; print $a;
  5. ?>

16
06
15
05
What will be the output of the following PHP code ?
  1. <?php
  2. $b = 1; $c = 4; $a = 5; 
  3. $d = $b + $c == $a;
  4. print $d;
  5. ?>

5
0
10
1
What will be the output of the following PHP code ?
  1. <?php
  2. echo 5 * 9 / 3 + 9;
  3. ?>

24
3.7
3.85
0
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 1 + ++5;
  3. echo $var1; 
  4. ?>

no output
error
6
7
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 0;
  3. $var1 = ($var1 + 5)++; 
  4. echo $var1; 
  5. ?>

5
error
6
7
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 0;
  3. $var1 = $var1++ + 5; 
  4. echo $var1; 
  5. ?>

5
error
6
7
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 0;
  3. $var1 = ++$var1 + 5; 
  4. echo $var1; 
  5. ?>

5
error
6
7
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 0;
  3. $var1 = $var1 + 5; 
  4. echo $var1++; 
  5. ?>

5
error
6
7
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 1;
  3. echo $var1 = ++$var1 % 2 + ++$var1; 
  4. ?>

1
0
2
3
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 3;
  3. print $var = ++$var;
  4. ?>

1
0
2
3
What will be the output of the following PHP code ?
  1. <?php
  2. $var1 = 3;
  3. print ++$var++;
  4. ?>

3
4
5
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. echo ++$a;
  4. echo $a++;
  5. echo $a;
  6. echo ++$a;
  7. ?>

11111213
11121213
11111212
11111112
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 12;
  3. --$a;
  4. echo $a++;
  5. ?>

11
12
10
error
What will be the output of the following PHP code ?
  1. <?php
  2. $x = "test";
  3. $y = "this";
  4. $z = "also"; 
  5. $x .= $y .= $z ;
  6. echo $x;
  7. echo $y;
  8. ?>

testthisthisalso
testthis
testthisalsothisalso
error at line 4
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 1;
  3. $y = 2;
  4. if (++$x == $y++)
  5. {
  6.     echo "true ", $y, $x;
  7. }
  8. ?>

no output
true 23
true 22
true 33
What will be the output of the following PHP code ?
  1. <?php
  2. $y = 2;
  3. $w = 4;
  4. $y *= $w /= $y;
  5. echo $y, $w;
  6. ?>

80.5
44
82
42
What will be the output of the following PHP code ?
  1. <?php
  2. $y = 2;
  3. if ($y-- == ++$y)
  4. {
  5.     echo $y;
  6. }
  7. ?>

2
1
3
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $y = 2;
  3. if (**$y == 4)
  4. {
  5.     echo $y;
  6. }
  7. ?>

4
2
error at line2
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $y = 2;
  3. if (--$y == 2 || $y xor --$y)
  4. {
  5.     echo $y;
  6. }
  7. ?>

1
0
2
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $y = 2;
  3. if (--$y <> ($y != $y++))
  4. {
  5.     echo $y;
  6. }
  7. ?>

1
0
2
no output
What will be the output of the following PHP code ?
  1. <?php
  2. echo $x-- != ++$x;
  3. ?>


1
0
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $auth = 1;
  3. $status = 1;
  4. if ($result = (($auth == 1) && ($status != 0)))
  5. {
  6.     print "result is $result<br>";
  7. }
  8. ?>

result is true
result is 1
error
no output