PHP MCQs
PHP MCQs
PHP MCQs
MCQs Correct
Answer
UNIT I(PHP Basics)
1. What does PHP stand for currently? B
A. Personal Home Page B. Hypertext Pre-processor
C. Pretext Hypertext Pre-processor D. Pretext Home Page
10. PHP Programmer can write the PHP code in which tags? D
A. Canonical Tag <?php //Code ?>
B. Short Tag <? //Code ?>
C. ASP Tag <% Code %>
D. All of the above
11. Which of the following is a composite PHP data-type? C
A. Integer
B. Boolean
C. Array
D. String
12. String within single quote is parsed whereas string within double B
quote is not parsed.
A. True
B. False
C. May be
15. Which PHP built-in function will help you to create constants? C
A. Const()
B. Constant()
C. Define()
D. Include()
A. bool(false)
B. bool(true)
C. 1
D. 0
20. I have declare a variable like; $n = 100; What will be the output of the B
commands echo $n<<2; and echo $n>>2 respectively?
A. 200 50
B. 400 25
C. 50 200
D. 25 400
<?php
function track() {
static $count = 0;
$count++;
echo $count;
}
track();
track();
track();
?>
A. 111 B 000
C. 123 D. 011
33. I have defined an array storing marks of the student with its C
associated subject name. I am interested in fetching both key and
value of this array. Which of the following construct should I use?
A. While
B. For
C. Foreach
D. Switch
A. Hello World
B. Infinite loop
C. no output
D. Error
A. Hii everyone
B. Hello World
C. Hello World Hii everyone
D. None of the above
A. $g=80
B. $g=160
C. $g=20
D. $g=10
48. Which of the following function displays the information about PHP and B
its configuration?
A. php_info()
B. phpinfo()
C. info()
D. None of the above
51. Which of the following is the correct way to create an array in PHP? B
A. $season = array["summer" , "winter" , "spring" , "autumn"];
B. $season = array("summer" , "winter" , "spring" , "autumn");
C. $season = "summer" , "winter" , "spring" , "autumn";
D. All of the above
52. Echo returns 1 on success whereas print does not return any value. B
A. True
B. False
55. I want to create a constant named COLLEGE with value “MKICS BCA”. C
Which line of code will help me?
A. const(‘COLLEGE’, ‘MKICS BCA’)
B. Constant(‘COLLEGE’, ‘MKICS BCA’)
C. Define(‘COLLEGE’, ‘MKICS BCA’)
D. Include(‘COLLEGE’, ‘MKICS BCA’)
E. None of these
56. I want to compare two values at the same time I am also looking C
forward that the data type of these values must also be same. Which
operator I should use?
A. =
B. ==
C. ===
D. strcasecmp( )
UNIT II(Functions)
57. How to define a function in PHP? D
A. function {function body}
B. type functionName(parameters) {function body}
C. functionName(parameters) {function body}
D. function functionName(parameters) {function body}
59. The function in PHP that can be used to concatenate array elements to A
form a single delimited string is –
A. implode()
B. concat()
C. explode()
D. concatenate()
63. Which of the following is the correct use of the strcmp() function in D
PHP?
A. The strcmp() function is used to compare the strings excluding
case
B. The strcmp() function is used to compare the uppercase strings
C. The strcmp() function is used to compare the lowercase strings
D. The strcmp() function is used to compare the strings including
case
A. Position:4
B. Position:30
C. Position:31
D. Position:5
A. 129::129::129
B. 130::130::130
C. 129::130::129
D. 130::129::130
A. 100::10
B. 100::100
C. 10:100
D. None of the above
70. Which of the following function by default returns the current time B
measured in the number of seconds since January 1 1970 00:00:00?
A. date()
B. time()
C. mktime()
D. curtime()
74. Assume that you have defined one array storing anything and you D
want to access the last element of the array. Which function you will
adopt?
A. current()
B. next()
C. prev()
D. end()
75. Which of the following function(s) can be used to compare two strings C
by ignoring their case?
A. strcmp()
B. compare()
C. strcasecmp()
D. All of these
77. Which of the following is a built-in function in PHP that adds a value to A
the end of an array?
A. array_push()
B. inend_array()
C. into_array()
D. None of the above
78. Which of the following function(s) is/are used to count total number D
of elements in an array?
A. Count
B. Sizeof
C. Array_count
D. Both count and sizeof
79. I have a number 34.0054 in a variable $x. I want to round up the value B
of this variable irrespective of whether the remaining part is greater
than equal to 5 or not, and store into a variable $y. Which statement
should I write?
A. $y = abs($x);
B. $y = ceil($x)
C. $y = floor($x)
D. $y = round($x)
80. Which of the following date function can be used to make sure a D
particular date is a valid date or not by providing month, day and year
respectively?
A. date()
B. detdate()
C. setdate()
D. checkdate()
81. When we use form method _______, then form data are visible in the A
URL.
A. get
B. post
C. request
D. All of these
E. None of these
83. Assume that you have designed a form having post method. Which D
amongst the following array will store the form data for processing?
A. $_GET
B. $_POST
C. $_REQUEST
D. Both $_POST and $_REQUEST
84. I have designed a form having one submit button and the name D
property of that button is save. Which of the following statement is
correct to check whether save element is present (set) in the
$_REQUEST array or not?
A. if ( present ($_REQUEST[‘save’]) )
B. if (isset $_REQUEST[‘save’] )
C. if ( isset ($_Request[‘save’]) )
D. if ( isset ($_REQUEST[‘save’]) )
86. Which of the following function can be used to redirect from one page C
to another page unconditionally?
A. include()
B. location()
C. header()
D. implode()
87. The function in PHP that can be used to concatenate array elements to A
form a single delimited string is -
A. implode()
B. concat()
C. explode()
D. concatenate()
88. We can retrieve the values of query string variables using _________ D
array.
A. Only $_GET
B. Only $_POST
C. Only $_REQUEST
D. Both $_GET and $_REQUEST
89. Which of the following form method of the form element is suggested A
to use when we want to pass sensitive information?
A. POST
B. GET
95. Which function needs to be called whenever we want to set or get the B
value of session variables?
A. start_session()
B. session_start()
C. mysql_session_start()
D. $_SESSION()
96. Which of the following function is used for both; setting the cookie D
variables as well as to destroy session variables?
A. $_COOKIE[]
B. $_COOKIE()
C. Unset()
D. Setcookie()
99. Sapna is a PHP programmer and she has stored the product id ‘P1254’ B
in a variable $pid. She wants to preserve this value for 7 days in a
variable named ck_pid. Which line of code she needs to write in order
to do so?
A. setcookie(“ck_pid”, $pid, 7 * 24 * 60 * 60);
B. setcookie(“ck_pid”, $pid, time() + 7 * 24 * 60 * 60);
C. setcookie(“ck_pid”, $pid,);
D. setcookie(“ck_pid”, $pid, time() - 7 * 24 * 60 * 60);
102. Which Program copies the databases from one server to another B
A. Mysqlflush
B. Mysqldbcopy
C. Mysqlflushdb
D. Mysqlcopydb
105. Assume Event table in some database having some records. Which C
SQL command you can use if you want to change the value of
Event_Time field of this table?
A. INSERT
B. ADD
C. UPDATE
D. ALTER
106. Suppose you have designed a database name “db_Quiz”. Which of the D
following line of code is used to select this database in the PHP
application? Assume that connection resource is stored in $con
variable.
A. mysqli_db_select($con, db_Quiz)
B. mysqli_db_select($con, “db_Quiz”)
C. mysqli_select_db($con, db_Quiz)
D. mysqli_select_db($con, “db_Quiz”)
107. While establishing connection of PHP with MySQL using C
mysqli_connect() function, we need to provide name of the MySQL
user. What is the default name of the MySQL user?
A. localhost
B. mysql
C. root
D. mysqli
110. Which of the following function will help you, if you want to get the C
number of rows present in the result set of SELECT query?
A. mysqli_fetch_row()
B. mysqli_num_row()
C. mysqli_num_rows()
D. None of these
111. Which of the following function will fetches a result row as an A
associative array, a numeric array, or both.
A. mysqli_fetch_array()
B. mysqli_fetch_row()
C. mysqli_fetch_assoc()
D. mysqli_result()
112. Which of the following function is used to add the content of some D
other file in the current script?
A. Require( )
B. Include( )
C. Include_once( )
D. All of the above
UNIT V(JQuery)
113. Which of the following jQuery method is used to stop jQuery for few B
milliseconds?
A. stop() method
B. delay() method
C. slowdown() method
D. pause() method
114. Which jQuery method is used to set one or more style properties to C
the selected element?
A. The html() method
B. The style() method
C. The css() method
D. All 3 options
115. The jQuery used to find all next sibling elements after the current B
element is –
A. find() method
B. nextAll() method
C. siblings() method
D. None of the above
116. Which of the following jQuery method is used to hide the selected B
elements?
A. The hidden() method
B. The hide() method
C. The visible(false) method
D. The display(none) method
118. Which tag is used to import the jQuery library file in the code? B
A. <head>
B. <script>
C. <import>
D. <style>
119. Which selector expression will hide all the elements having class cute? B
A. $(.cute).hide();
B. $(“.cute”).hide();
C. $(“#cute”).hide();
D. $(“.cute”).hides();
120. Pick the odd one out. C
A. fadeIn()
B. fadeOut()
C. show()
D. fadeTo()
121. Which of the following jQuery method is used to sets or gets the value D
of form control?
A. html()
B. text()
C. value()
D. val()
122. The ____________ method removes the child elements from the A
selected element whereas the ______________ method removes the
selected element and its child elements.
A. empty() and remove()
B. remove() and empty()
C. delete() and remove()
D. remove() and delete()
125. Which of the following selector expression will select the element B
having id “hdng”?
A. $(#hdng)
B. $(‘#hdng’)
C. $(‘.hdng’)
D. $(hdng)
126. Which of the following method does not provides sliding effect? C
A. slideUp()
B. slideDown()
C. fadeIn()
D. slideToggle()
129. Which of the following jQuery filtering method returns all elements D
that do not match the criteria?
A. first( )
B. last( )
C. filter( )
D. not( )
131. Which of the following jQuery method is used to sets or get one or B
more style properties for the selected elements?
A. html( )
B. css()
C. val()
D. addCSS()