1.
PHP files have a default file extension of_______
a) .html
b) .xml
c) .php
d) .ph
2. Which of the following PHP statement/statements will store 111 in variable num?
i) int $num = 111;
ii) int mum = 111;
iii) $num = 111;
iv) 111 = $num;
a) Both i & ii
b) i,ii,iii & iv
c) Only iii
d) Only i
3. What does PHP stand for?
i) Personal Home Page
ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor
iv) Preprocessor Home Page
a) Both i & iii
b) Both ii & iv
c) Only ii
d) Both i & ii
4. Which of the decision making statements is/are supported by PHP?
i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements
a) Both i & iii
b) Both ii & iv
c) Only ii
d) all i, ii,iii,iv
5. What will be the output of the following PHP code?
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
b) I love red color
c) i love pink color
d) i love yellow color
6. Which one is not a data type in PHP?
A. Resources
B. Objects
C. Null
D. Void
7.What will be the output of the following PHP code?
<?php
$str= NULL;
echo $str;
?>
A. 0
B. Null
C. No Output
D. Error
8.What will be the output of the following PHP code?
<?php
$intArray = array( 10, 20 , 30);
echo "First Element: $intArray[2]";
?>
A. First Element: 10
B. First Element: 20
C. First Element: 30
D. First Element:
9.Any variables declared in PHP must begin with a _____?
A. .
B. #
C. &
D. $
10. A variable name can only contain ____________?
A. alphanumeric,characters
B. underscores
C. Both A and B
D. None of the above
11. How many variable scope are there in php?
A. 2
B. 3
C. 1
D. 4
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
14. How many main parameter are used in for loop?
A. 2
B. 3
C. 4
D. 1
15. foreach loop is used to iterate over ____?
A. number
B. object
C. function
D. array
16. What will be the output of the following PHP code?
<?php
$arr = array (10, 20, 30);
foreach($arr as $val)
{
echo $val;
?>
A. 10 20 30
B. No Output
C. 10
D. undefined variable
17. What will be the output of the following PHP code?
<?php
$x = 3.3;
$y = 2;
echo $x % $y;
?>
A. 1.3
B. 1
C. 0
D. Error
18. By default, the index of array in php starts from ______?
A. 0
B. 1
C. -1
D. 2
19. How many different data types are available in php?
A. 6
B. 7
C. 8
D. 9
20. What will be the output of the following PHP code?
<?php
if(TRUE)
echo "This condition is TRUE";
if(FALSE)
echo "This condition is not TRUE";
?>
A. This condition is TRUE
B. This condition is not TRUE
C. No Output
D. Error
21. How many ways can a session data be stored?
a) 3
b) 4
c) 5
d) 6
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
23. If session.use_cookie is set to 0, this results in use of _____________
a) Session
b) Cookie
c) URL rewriting
d) Nothing happens
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
25. Which one of the following function is used to start a session?
a) start_session()
b) session_start()
c) session_begin()
d) begin_session()
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”);
A. (i) and (ii)
B. (i), (ii) and (iii)
C. All of the mentioned
D. (i), (ii) and (iv)
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()
29. Which of the following is used to create a session?
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
D - None of the above.
31.Which of the following is used to destroy the session?
A - session_start() function
B - $_SESSION[]
C - isset() function
D - session_destroy() function
32-Which of the following array represents an array with strings as index?
A - Numeric Array
B - Associative Array
C - Multidimentional Array
D - None of the above.
33.Cookies were originally designed for
A.Client side programming
B.Server side programming
C.Both a and b
D.None of the mentioned
34.What is the constraint on the data per cookie?
A . 2 KB B. 1 KB C . 4 KB D . 3 KB
35.How can you set a Cookie visibility scope to local Storage?
A./ B.% C.* D . All of the mentioned