PHP

PHP

If – Else – If has 30 Questions
What will be the output of the following PHP code?
  1. <?php
  2. $x;
  3. if ($x)
  4.     print "hi" ;
  5. else
  6.     print "how are u";
  7. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 0;
  3. if ($x++)
  4.     print "hi";
  5. else
  6.     print "how are u";
  7. ?>

hi
no output
error
how are u
What will be the output of the following PHP code ?
  1. <?php
  2. $x;
  3. if ($x == 0)
  4.     print "hi" ;
  5. else
  6.     print "how are u";
  7.     print "hello"
  8. ?>

how are uhello
hihello
hi
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 0;
  3. if ($x == 1)
  4.     if ($x >= 0)
  5.         print "true";
  6.     else
  7.         rint "false"; 
  8. ?>

true
false
error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 1;
  3. if ($a--)
  4.     print "True";
  5. if ($a++)
  6.     print "False"; 
  7. ?>

true
false
error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 1;
  3. if (echo $a)
  4.     print "True";
  5. else
  6.     print "False"; 
  7. ?>

true
false
error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 1;
  3. if (print $a)
  4.     print "True";
  5. else
  6.     print "False"; 
  7. ?>

true
false
error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. if (1) 
  4.     print "all";
  5. else 
  6.     print "some"
  7. else 
  8.     print "none";
  9. ?>

all
some
error
none
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. if (1) 
  4.     print "all";
  5. else 
  6.     print "some"
  7. else 
  8.     print "none";
  9. ?>

all
some
error
none
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. if (0) 
  4.     print "all";
  5.  if 
  6.  else 
  7.      print "some"
  8. ?>

all
some
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "";
  3. if ($a) 
  4.     print "all";
  5. if 
  6. else 
  7.     print "some";
  8. ?>

all
some
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "a";
  3. if ($a) 
  4.     print "all";
  5. else 
  6.     print "some";
  7. ?>

all
some
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 20;
  4. if ($x > $y + $y != 3)
  5.     print "hi" ;
  6. else
  7.     print "how are u";
  8. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 20;
  4. if ($x > $y && 1||1)
  5.     print "hi" ;
  6. else
  7.     print "how are u";
  8. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 20;
  4. if ($x > $y && 1||1)
  5.     print "hi" ;
  6. else
  7.     print "how are u";
  8. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. if (-100)
  3.     print "hi" ;
  4. else
  5.     print "how are u";
  6. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. if (0.0)
  3.     print "hi" ;
  4. else
  5.     print "how are u";
  6. ?>

how are u
hi
Error
No output
What will be the output of the following PHP code ?
  1. <?php
  2. if (print "0")
  3.     print "hi" ;
  4. else
  5.     print "how are u";
  6. ?>

0how are u
0hi
hi
how are u
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 1;
  3. if ($x == 2)
  4.     print "hi" ;
  5. else if($x = 2)
  6.     print $x;
  7. else
  8.     print "how are u";
  9. ?>

error
2
hi
how are u
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 1;
  3. if ($x = $x&0)
  4.     print $x ;
  5. else
  6.     print "how are u";
  7. ?>

0
1
error
how are u
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 1;
  3. if ($x = $x&0)
  4.     print $x ;
  5. else
  6.     print "how are u";
  7. ?>

0
1
error
how are u
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 1;
  3. if ($x = $x&0)
  4.     print $x;
  5. else
  6.     break;
  7. ?>

0
1
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 100;
  3. if ($a > 10)
  4.     printf("M.S. Dhoni");
  5. else if ($a > 20)
  6.     printf("M.E.K Hussey");
  7. else if($a > 30)
  8.     printf("A.B. de villiers");
  9. ?>

M.S.Dhoni
M.E.K.Hussey
M.S.Dhoni M.E.K.Hussey A.B.de villiers
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $x = 10;
  3. $y = 5;
  4. $z = 3;
  5. if ($x / $y / $z)
  6.     print "hi";
  7. else
  8.     print "hello";
  9. ?>

hi
hello
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. if (!print "hi")
  3.     if (print "hello")
  4. print "hi";
  5. ?>

hi
hihellohi
hihi
no output
What will be the output of the following PHP code ?
  1. <?php
  2. if (print "hi" - 1)
  3.     print "hello"
  4. ?>

hi
hihello
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "1";
  3. $b = "0";
  4. if ((int)$a && $b) 
  5.     print"hi";
  6. else 
  7.     print "hello";
  8. ?>

hello
no output
hi
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "hello";
  3. if (strlen($a))
  4.     print strlen($a);
  5. else
  6.     print "hi";
  7. ?>

hellolength
5
hi
error
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 2;
  3. if ($a-- - --$a - $a)
  4.     print "hello";
  5. else
  6.     print "hi";
  7. ?>

hi
hello
error
no output
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 10;
  3. $b = 11;
  4. if ($a < ++$a || $b < ++$b)
  5.     print "hello";
  6. else
  7.     print "hi";
  8. ?>

hi
hello
error
no output