

MCQOPTIONS
Saved Bookmarks
This section includes 57 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.
1. |
What will be the output of the following PHP code ?<?phpfunction _message(){ echo "Welcome to the Interview Mania";}_message();?> |
A. | Welcome to the Interview Mania |
B. | Error |
C. | Nothing |
D. | _message |
E. | None of these |
Answer» B. Error | |
2. |
What will be the output of the following PHP code ?<?php $p = 45;$q = 26; function add(){ $GLOBALS['r'] = $GLOBALS['p'] + $GLOBALS['q'];}add();echo $r;?> |
A. | Error |
B. | 45 |
C. | 26 |
D. | 71 |
E. | None of these |
Answer» E. None of these | |
3. |
What will be the output of the following PHP code ?<?phpfunction 15function(){ echo "Hello Interview Mania";}15function();?> |
A. | Error |
B. | Hello |
C. | Interview Mania |
D. | Hello Interview Mania |
E. | None of these |
Answer» B. Hello | |
4. |
What will be the output of the following PHP code ?<?phpfunction fun($m) { if ($m < 10) echo "True"; if ($m >= 10) echo "False"; }fun(20);?> |
A. | Error |
B. | True |
C. | Nothing |
D. | False |
E. | None of these |
Answer» E. None of these | |
5. |
What will be the output of the following PHP code ?<?phpfunction fun($str) { echo "favourite fun time is ".$str; function b() { echo "Inside block executed..."; } }function p() { echo "Outside block executed..."; }p();?> |
A. | favourite fun time is |
B. | Inside block executed... |
C. | Outside block executed... |
D. | Error |
E. | None of these |
Answer» D. Error | |
6. |
What will be the output of the following PHP code ?<?phpfunction Condition($number) { if ($number == 3) echo "Condition 3rd executed...."; if ($number == 7) echo "Condition 7th executed...."; if ($number == 8) echo "Condition 8th executed...."; if ($number == 19) echo "Condition 19th executed...."; }$var = stripos("I know the php, And I love to know php!","the");Condition($var);?> |
A. | Condition 3rd executed.... |
B. | Condition 7th executed.... |
C. | Condition 8th executed.... |
D. | Condition 19th executed.... |
E. | None of these |
Answer» C. Condition 8th executed.... | |
7. |
What will be the output of the following PHP code ?<?phpfunction TvShow($int){ $TvShow = array("Naagin.", "CID.", "Big Boss."); echo "This is my favourite show ". $TvShow[$int];}TvShow(2);?> |
A. | This is my favourite show Naagin. |
B. | This is my favourite show CID. |
C. | This is my favourite show Big Boss. |
D. | Error |
E. | None of these |
Answer» D. Error | |
8. |
What will be the output of the following PHP code ?<?phpfunction First($str){ echo "This is ". $Str;}First("Important");?> |
A. | Important |
B. | This is |
C. | Error |
D. | This is Important |
E. | None of these |
Answer» D. This is Important | |
9. |
What will be the output of the following PHP code ?<?phpfunction Example($d){ $d = 12 + $d; echo "$d";}Example(6);?> |
A. | 12 |
B. | 6 |
C. | 18 |
D. | $d |
E. | None of these |
Answer» E. None of these | |
10. |
What will be the output of the following PHP code ?<?phpfunction fun($number){ $number = 5 + $number;echo $number;}fun(7);?> |
A. | 5 |
B. | 7 |
C. | 12 |
D. | Error |
E. | None of these |
Answer» D. Error | |
11. |
What will be the output of the following PHP code ?<?phpfunction constant(){ define("MESSAGE", "Welcome to Interview Mania"); echo MESSAGE;}?> |
A. | MESSAGE, Welcome to Interview Mania |
B. | Error |
C. | Welcome to Interview Mania |
D. | Nothing |
E. | None of these |
Answer» C. Welcome to Interview Mania | |
12. |
What will be the output of the following PHP code ?<?phpfunction fun($str){ echo strtr("Towe Pa55", "ow5", $str);}fun("ims");?> |
A. | Time Pass |
B. | Error |
C. | Towe Pa55 |
D. | Nothing |
E. | None of these |
Answer» B. Error | |
13. |
What will be the output of the following PHP code ?<?phpfunction SumFun($number1, $number2){ $s = $number1 + $number2; return $s;}$return_val = SumFun(15, 45);echo "Returned value : " .$return_val?> |
A. | Returned value : 60 |
B. | Returned value : 15 |
C. | Returned value : 45 |
D. | Error |
E. | None of these |
Answer» B. Returned value : 15 | |
14. |
What will be the output of the following PHP code ?<?phpfunction calculation($n1, $n2) { $n3 = $n1 * $n2; }$R = calculation(12, 25);echo $R; ?> |
A. | 12 |
B. | 25 |
C. | Error |
D. | 37 |
E. | None of these |
Answer» D. 37 | |
15. |
What will be the output of the following PHP code ?<?phpfunction calculate($n1, $n2) { $n3 = $n1 * $n2; return $n3; }$R = calculate(22, 23);echo $R; ?> |
A. | 22 |
B. | 23 |
C. | Error |
D. | 506 |
E. | None of these |
Answer» E. None of these | |
16. |
What will be the output of the following PHP code ?<?php$num = 120;function calc() { echo $num; }calc();?> |
A. | Nothing |
B. | 120 |
C. | Error |
D. | 20 |
E. | None of these |
Answer» B. 120 | |
17. |
What will be the output of the following PHP code ?<?phpfunction fun($str) { echo "hello n".$str; function Z() { echo "Inside block executed... n"; } }function Z() { echo "Outside block executed... n"; }Z();fun("Interview Mania");?> |
A. | Error |
B. | Inside block executed... |
C. | Outside block executed... |
D. | Interview Mania |
E. | None of these |
Answer» B. Inside block executed... | |
18. |
What will be the output of the following PHP code ?<?phpfunction fun(){ $EmailId1 = "Interview@Mania.com"; $EmailId2 = strstr($EmailId1, '@'); echo $EmailId2;}fun();?> |
A. | Interview@Mania.com |
B. | Error |
C. | Nothing |
D. | @Mania.com |
E. | None of these |
Answer» E. None of these | |
19. |
What will be the output of the following PHP code ?<?phpfunction str($Message) { $Message = ucwords($Message); echo lcfirst($Message); }str("this is important...");?> |
A. | this Is Important... |
B. | this is important... |
C. | Error |
D. | Nothing |
E. | None of these |
Answer» B. this is important... | |
20. |
What will be the output of the following PHP code ?<?phpfunction fun($str) { echo "my favourite fun time is ".$str; function m() { echo " to spend with friends"; } }m();?> |
A. | my favourite fun time is |
B. | Nothing |
C. | to spend with friends |
D. | Error |
E. | my favourite fun time is to spend with friends |
Answer» E. my favourite fun time is to spend with friends | |
21. |
What will be the output of the following PHP code ?<?phpfunction str(){ echo strstr("Interview Mania!", 118);}str();?> |
A. | Interview |
B. | Mania |
C. | view Mania! |
D. | Error |
E. | None of these |
Answer» D. Error | |
22. |
What will be the output of the following PHP code ?<?phpfunction uppercase($str) { echo ucwords($str); }$fun = "uppercase";$fun("time to do a great job.");?> |
A. | Error |
B. | Time To Do A Great Job. |
C. | time to do a great job. |
D. | Nothing |
E. | None of these |
Answer» C. time to do a great job. | |
23. |
What will be the output of the following PHP code ?<?phpfunction fun($opt) { switch($opt) { case 10: echo 'Case 10 will execute.'; break; case 20: echo 'Case 20 will execute.'; break; case 30: echo 'Case 30 will execute.'; break; case 40: echo 'Case 40 will execute.'; break; default: echo 'Default will execute.'; break; } }fun(20);?> |
A. | Case 10 will execute. |
B. | Case 20 will execute. |
C. | Case 30 will execute. |
D. | Case 40 will execute. |
E. | Default will execute. |
Answer» C. Case 30 will execute. | |
24. |
What will be the output of the following PHP code?<?phpfunction calculation($Rs, $tax="") { $Result = $Rs + ($Rs * $tax); echo "$Result"; }calculation(80); ?> |
A. | 160 |
B. | 0 |
C. | Erro |
D. | 80 |
E. | None of these |
Answer» E. None of these | |
25. |
What will happen in this function call?<?php function calc($num, $num1) { $sum = $num + $num1; echo $sum; }$n = 20;$n1 = 10;calc($n, $n1); ?> |
A. | Call By Reference |
B. | Type Hinting |
C. | Call By Value |
D. | Default Argument Value |
E. | None of these |
Answer» D. Default Argument Value | |
26. |
What will be the output of the following PHP code?<?php function fun1() { function fun2() { echo 'I am Ajit.'; } echo 'I am Rahul'; }fun2();fun1();?> |
A. | Error |
B. | I am Ajit. |
C. | I am Rahul. |
D. | I am Rahul. I am Ajit. |
E. | None of these |
Answer» B. I am Ajit. | |
27. |
What will be the output of the following PHP code?<?php$option2 = "Mania";function fun($option1) { echo $option1; echo $option2; }fun("Interview");?> |
A. | Error |
B. | Mania |
C. | Interview |
D. | Interview Mania |
E. | None of these |
Answer» D. Interview Mania | |
28. |
What will be the output of the following PHP code? <?php function fun1() { function fun2() { echo 'I am Ajit.'; } echo 'I am Rahul. '; }fun1();fun2();?> |
A. | I am Rahul. |
B. | I am Ajit. |
C. | I am Rahul. I am Ajit. |
D. | Error |
E. | None of these |
Answer» D. Error | |
29. |
What will be the output of the following PHP code?<?phpdefine("GREETING","Welcome to interview mania!");echo constant("GREETING");?> |
A. | Welcome to interview mania! |
B. | GREETING Welcome to interview mania! |
C. | Error |
D. | Nothing |
E. | None of these |
Answer» B. GREETING Welcome to interview mania! | |
30. |
What will be the output of the following PHP code?<?phpecho stripos("I know the php, I love to know the php too!","know");?> |
A. | I know the php, I love to know the php too! |
B. | Error |
C. | 2 |
D. | 7 |
E. | None of these |
Answer» D. 7 | |
31. |
What will be the output of the following PHP code?<?phpecho chr(55);?> |
A. | 7 |
B. | 5 |
C. | 3 |
D. | 1 |
E. | None of these |
Answer» B. 5 | |
32. |
What will be the output of the following PHP code?<?phpecho ord ("Ajit");?> |
A. | 61 |
B. | 62 |
C. | 63 |
D. | 64 |
E. | 65 |
Answer» F. | |
33. |
What will be the output of the following PHP code?<?phpecho chr(51);?> |
A. | 51 |
B. | 15 |
C. | 3 |
D. | Error |
E. | None of these |
Answer» D. Error | |
34. |
What will be the output of the following PHP code?<?phpecho ord ("Rahul");?> |
A. | 81 |
B. | 82 |
C. | 83 |
D. | 84 |
E. | 85 |
Answer» C. 83 | |
35. |
What will be the output of the following PHP code?<?phpecho(atan(0.60));?> |
A. | Error |
B. | 0.54041950027058 |
C. | Nothing |
D. | 0.6021356432146 |
E. | None of these |
Answer» C. Nothing | |
36. |
What will be the output of the following PHP code?<?php$option2 = "Hey";function fun($option1) { echo $option1; echo $option2; }fun("Welcome");?> |
A. | Error |
B. | Welcome |
C. | Hey |
D. | Nothing |
E. | None of these |
Answer» C. Hey | |
37. |
What will be the output of the following PHP code?<?phpfunction n() { function m() { echo 'M'; } echo 'N'; }m();n();?> |
A. | Nothing |
B. | Error |
C. | M |
D. | N |
E. | None of these |
Answer» C. M | |
38. |
What will be the output of the following PHP code?<?php$string = "Hello Interview Mania. It's a knowledgeable website.";print_r (explode(" ",$string));?> |
A. | Hello Interview Mania. It's a knowledgeable website. |
B. | Error |
C. | None of these |
Answer» B. Error | |
39. |
What will be the output of the following PHP code?<?phpfunction calculate($p, $t="") { $total = $p + ($p * $t); echo "$total"; }calculate(65); ?> |
A. | Nothing |
B. | Error |
C. | 56 |
D. | 65 |
E. | None of these |
Answer» E. None of these | |
40. |
What will be the output of the following PHP code?<?phpecho strtr("Hilla Interview Mania","ia","eo");?> |
A. | Hilla Interview Mania |
B. | Error |
C. | Nothing |
D. | Hello Interveew Moneo |
E. | None of these |
Answer» E. None of these | |
41. |
What will be the output of the following PHP code?<?phpecho hex2bin("496e74657276696577204d616e6961");?> |
A. | Interview |
B. | Interview Mania |
C. | Error |
D. | Mania |
E. | None of these |
Answer» C. Error | |
42. |
What will be the output of the following PHP code?<?php $string = addslashes('how are "you" doing?');echo $string; ?> |
A. | how are "you" doing? |
B. | how are you doing? |
C. | how are "you " doing? |
D. | Error |
E. | None of these |
Answer» D. Error | |
43. |
What will be the output of the following PHP code?<?phpfunction fun($Str){ echo strpos($Str, "good",0);}fun("The Interview Mania is good for study.");?> |
A. | good |
B. | Error |
C. | 23 |
D. | Nothing |
E. | None of these |
Answer» D. Nothing | |
44. |
What will be the output of the following PHP code?<?phpfunction HelloFuncation(){ echo "Hello Interview Mania n";}$fun_holder = "HelloFuncation";$fun_holder();?> |
A. | Hello |
B. | Interview |
C. | Mania |
D. | Hello Interview Mania |
E. | None of these |
Answer» D. Hello Interview Mania | |
45. |
What will be the output of the following PHP code?<?phpecho ucwords("i love interview mania!");?> |
A. | Interview Mania! |
B. | Error |
C. | i love interview mania! |
D. | Nothing |
E. | I Love Interview Mania! |
Answer» F. | |
46. |
What will be the output of the following PHP code?<?phpfunction addation($n1, $n2){ $add = $n1 + $n2; return $add;}$return_val = addation(50, 70);echo "Returned value : $return_val"?> |
A. | Returned value : 120 |
B. | Returned value : 50 |
C. | Returned value : 70 |
D. | Error |
E. | None of these |
Answer» B. Returned value : 50 | |
47. |
What will be the output of the following PHP code?<?phpecho ucwords("this is an important.");?> |
A. | Error |
B. | this is an important. |
C. | Nothing |
D. | This Is An Important. |
E. | None of these |
Answer» E. None of these | |
48. |
What will be the output of the following PHP code?<?phpecho str_pad("This", 10)." theory is good.";?> |
A. | This theory is good. |
B. | Error |
C. | Nothing |
D. | This theory is good. |
E. | None of these |
Answer» B. Error | |
49. |
What will be the output of the following PHP code?<?php$title = "interview mania founded by manjesh ojha";echo ucwords($title);?> |
A. | Error |
B. | Interview Mania Founded By Manjesh Ojha |
C. | interview mania founded by manjesh ojha |
D. | Nothing |
E. | None of these |
Answer» C. interview mania founded by manjesh ojha | |
50. |
What will be the output of the following PHP code?<?phpfunction First(){ define("const","Interview mania is awesome!"); echo constant("const");}First();?> |
A. | Error |
B. | Interview mania is awesome! |
C. | const, Interview mania is awesome! |
D. | Nothing |
E. | None of these |
Answer» C. const, Interview mania is awesome! | |