MCQOPTIONS
Saved Bookmarks
This section includes 20 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 is the value of $a and $b after the function call?<?phpfunction doSomething(&$argument) { $Result = $argument; $argument += 1; return $Result; }$n = 5;$m = doSomething($n);echo "n = " . $n . " and m = " . $m;?> |
| A. | n = 6 |
| B. | n = 6 and m = 5 |
| C. | m = 6 |
| D. | Error |
| E. | None of these |
| Answer» C. m = 6 | |
| 2. |
What will be the output of the following PHP code?<?php$user = array("Ats ", "Ajit ", "Rahul ", "Aju ");for ($str=0; $str < count($user); $str++) {if ($user[$str] == "Rahul ") continue;printf ($user[$str]); }?> |
| A. | Error |
| B. | Rahul |
| C. | Ats Ajit Aju |
| D. | Ats Ajit Rahul Aju |
| E. | None of these |
| Answer» D. Ats Ajit Rahul Aju | |
| 3. |
What will be the output of the following PHP code?<?php$math = "25 students";$Science = 35;$math = $math + $Science;echo "$math";?> |
| A. | 25 |
| B. | 35 |
| C. | Error |
| D. | 60 |
| E. | None of these |
| Answer» E. None of these | |
| 4. |
What will be the output of the following PHP code?<?php$num = 10120;$num1 = (array) $num;echo $num1[0];?> |
| A. | 10120 |
| B. | Error |
| C. | 101 |
| D. | 120 |
| E. | None of these |
| Answer» B. Error | |
| 5. |
What will be the output of the following code?<?php $name = 'Ajit'; $temp = &$name; $temp = "My name is $temp. "; echo $temp;echo $name;?> |
| A. | AjitAjit |
| B. | My name is Ajit. My name is Ajit. |
| C. | Ajit |
| D. | Error |
| E. | None of these |
| Answer» C. Ajit | |
| 6. |
What will be the output of the following PHP code?<?php$var = "YELLOW";$var1 = $var[5];echo "$var1";?> |
| A. | Y |
| B. | E |
| C. | L |
| D. | O |
| E. | W |
| Answer» E. W | |
| 7. |
What will be the output of the following PHP code?<?php$State = "Chennai";switch ($State) {case "Mumbai":echo "I love Mumbai. ";case "Chennai":echo "I love Chennai. ";case "Rajshathan":echo "I love Rajshatan. "; }?> |
| A. | I love Chennai. I love Mumbai. |
| B. | I love Mumbai. |
| C. | Error |
| D. | I love Chennai. I love Rajshatan. |
| E. | None of these |
| Answer» E. None of these | |
| 8. |
What will be the output of the following code?<?phpfunction track() { static $var = 0; $var++; echo $var; } track(); track(); track();?> |
| A. | 000 |
| B. | 010 |
| C. | 110 |
| D. | 123 |
| E. | None of these |
| Answer» E. None of these | |
| 9. |
What will be the output of the following PHP code? |
| A. | Error |
| B. | What is her age? n She is 18 years old |
| C. | What is her age? n She is $n years old. |
| D. | 18 |
| E. | None of these |
| Answer» D. 18 | |
| 10. |
What will be the output of the following PHP code?<?php$num = 6;$num1 = 6;echo ($num === $num1);?> |
| A. | Error |
| B. | 1 |
| C. | False |
| D. | 6 === 6 |
| E. | None of these |
| Answer» C. False | |
| 11. |
What will be the output of the following PHP code?<?php$str = "Interview";$str .= "Mania";echo "$str";?> |
| A. | Interview |
| B. | Error |
| C. | Mania |
| D. | InterviewMania |
| E. | None of these |
| Answer» E. None of these | |
| 12. |
What will be the output of the following php code?<?php$n = 10;$n1 = 12;print $n . "+". $n1;?> |
| A. | 10 |
| B. | 12 |
| C. | 10+12 |
| D. | 12+10 |
| E. | Error |
| Answer» D. 12+10 | |
| 13. |
What will be the output of the following php code?<?php$n = "12";$n1 = "21";print $n+$n1;?> |
| A. | 33 |
| B. | Error |
| C. | 12+21 |
| D. | 12 |
| E. | 21 |
| Answer» B. Error | |
| 14. |
What does PHP stand for? |
| A. | Hypertext Preprocessor |
| B. | Pretext Hypertext Processor |
| C. | Personal Home Page |
| D. | Preprocessor Home Page |
| E. | Both A and C |
| Answer» F. | |
| 15. |
Which of the following php statement/statements will store 120 in variable n? |
| A. | 120 = $n; |
| B. | int $n= 120; |
| C. | int n= 120; |
| D. | $n= 120; |
| E. | None of these |
| Answer» E. None of these | |
| 16. |
Which of the following PHP statements will output Hello interview Mania on the screen? |
| A. | sprintf ( Hello interview Mania ); |
| B. | echo ( Hello interview Mania ); |
| C. | print ( Hello interview Mania ); |
| D. | printf ( Hello interview Mania ); |
| E. | B, C and D |
| Answer» F. | |
| 17. |
Which of the below statements is equivalent to $sum+= $sum ? |
| A. | $sum= $sum+$sum |
| B. | $sum= $sum |
| C. | $sum= $sum+ $sum+ 1 |
| D. | $sum= $sum+ 1 |
| E. | None of these |
| Answer» B. $sum= $sum | |
| 18. |
Which of following variables can be assigned a value to it? |
| A. | $this |
| B. | $3hello |
| C. | $This |
| D. | $_hello |
| E. | Both C and D |
| Answer» F. | |
| 19. |
If $n = 25 what will be returned when (($n == 25) ? 5 : 1) is executed? |
| A. | 5 |
| B. | 1 |
| C. | 25 |
| D. | Error |
| E. | None of these |
| Answer» D. Error | |
| 20. |
Which of the looping statements is/are supported by PHP? |
| A. | for each loop |
| B. | do-while loop |
| C. | while loop |
| D. | for loop |
| E. | All of above |
| Answer» F. | |