PHP

PHP

Switch has 9 Questions
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "1";
  3. switch ($a)
  4. {
  5. case 1:
  6.     print "hi";
  7. case 2:
  8.     print "hello";
  9. default:
  10.     print "hi1";
  11. }
  12. ?>

hihellohi1
hi
hihi1
hi1
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "2";
  3. switch ($a)
  4. {
  5. case 1:
  6.     print "hi";
  7. case 2:
  8.     print "hello";
  9.     break;
  10. default:
  11.     print "hi1";
  12. }
  13. ?>

hihellohi1
hello
hihi1
hi1
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "1";
  3. switch($a)
  4. {
  5. case 1:
  6.     break;
  7.     print "hi";
  8. case 2:
  9.     print "hello";
  10.     break;
  11. default:
  12.     print "hi1";
  13. }
  14. ?>

hihellohi1
no output
hihi1
hi1
What will be the output of the following PHP code ?
  1. <?php
  2. $a = "1";
  3. $a = 1;
  4. $b = 1;
  5. switch($a)
  6. {
  7. case $a * $b: 
  8.     print "hi";
  9.     break;
  10. case $a / $b:
  11.     print "hello";
  12.     break;
  13. default:
  14.     print "hi1";
  15. }
  16. ?>

hihellohi1
hi
hihello
hi1
What will be the output of the following PHP code ?
  1. <?php
  2. $a = 97;
  3. switch($a)
  4. {
  5. case "a":
  6.     print "hi";
  7.     break;
  8. case 97:
  9.     print "hello";
  10.     break;
  11. default:
  12.     print "hi1";
  13. }
  14. ?>

hihellohi1
hi
hihello
hello
What will be the output of the following PHP code ?
  1. <?php
  2. $b = 1;
  3. switch($b)
  4. {
  5. case 1.0:
  6.     print "hi";
  7.     break;
  8. case 1:
  9.     print "hello";
  10.     break;
  11. default:
  12.     print "hi1";
  13. }
  14. ?>

hihellohi1
hi
hihello
hello
What will be the output of the following PHP code ?
  1. <?php
  2. const $b = 1;
  3. switch($b)
  4. {
  5. case 1:
  6.     print "hi";
  7.     break;
  8. case 1:
  9.     print "hello";
  10.     break;
  11. default:
  12.     print "hi1";
  13. }
  14. ?>

error
hi
hihello
hello
What will be the output of the following PHP code ?
  1. <?php
  2. switch($b)
  3. {
  4. case 2:
  5.     print "hello";
  6.     break;
  7. case 1:
  8.     print "hi";
  9.     break;
  10. }
  11. ?>

hello
hi
no output
error
What will be the output of the following PHP code ?
  1. <?php
  2. switch($b)
  3. {
  4. case 2:
  5.     print "hello";
  6.     break;
  7. case b:
  8.     print "hi";
  9.     break;
  10. }
  11. ?>

hello
hi
no output
error