PHP MCQ Questions
PHP MCQ Questions
PHP MCQ Questions
2. Which of the following PHP statement/statements will store 111 in variable num?
a) Both i & ii
b) i,ii,iii & iv
c) Only iii
d) Only i
b) Both ii & iv
c) Only ii
d) Both i & ii
i) if statements
ii) if-else statements
b) Both ii & iv
c) Only ii
d) all i, ii,iii,iv
1. <?php
2. $color= "red";
3. switch ($color) {
4. case "red":
5. echo "I love red color";
6. case "pink":
7. echo "I love pink color";
8. case "yellow":
9. echo "I love yellow color"; }
10. ?>
a) Error
A. Resources
B. Objects
C. Null
D. Void
<?php
$str= NULL;
echo $str;
?>
A. 0
B. Null
C. No Output
D. Error
<?php
?>
A. First Element: 10
B. First Element: 20
C. First Element: 30
D. First Element:
12. The PHP function searches for a specific text within a string.
A. strpos()
B. strposition()
C. strrev()
D. str_replace()
13 .The ___________ function can be used to compare two strings using a case-
insensitive binary algorithm.
A) strcmp()
B) stricmp()
C) strcasecmp()
D) None of the above
<?php
foreach($arr as $val)
{
echo $val;
?>
A. 10 20 30
B. No Output
C. 10
D. undefined variable
<?php
$x = 3.3;
$y = 2;
echo $x % $y;
?>
A. 1.3
B. 1
C. 0
D. Error
<?php
if(TRUE)
if(FALSE)
?>
22. Which directive determines how the session information will be stored?
a) save_data
b) session.save
c) session.save_data
d) session.save_handler
24. If the directive session.cookie_lifetime is set to 3600, the cookie will live until
____________
a) 3600 sec
b) 3600 min
c) 3600 hrs
d) the browser is restarted
26. Which of the following PHP statements will output Hello World on the screen?
(i) echo (“Hello World”);
(ii) print (“Hello World”);
(iii) printf (“Hello World”);
(iv) sprintf (“Hello World”);
27.Which of the following is an array containing information such as headers, paths, and script
locations?
A - $GLOBALS
B - $_SERVER
C - $_COOKIE
D - $_SESSION
28. Which of the following function can be used to get an array in the reverse order?
A - array_reverse()
B - array_search()
C - array_shift()
D - array_slice()
A - session_start() function
B - $_SESSION[]
C - isset() function
D - session_destroy() function
30. Which of the following can be used to get information sent via get/post method in PHP?
A - $_REQUEST
B - $REQUEST
C - $REQUEST_PAGE
A - session_start() function
B - $_SESSION[]
C - isset() function
D - session_destroy() function
A - Numeric Array
B - Associative Array
C - Multidimentional Array
C.Both a and b
A . 2 KB B. 1 KB C . 4 KB D . 3 KB