0% found this document useful (0 votes)
311 views

PHP & MySQL Question Bank

This document contains a list of 59 multiple choice questions about PHP and MySQL. It covers topics like PHP variables, arrays, functions, operators, and MySQL commands. The questions are related to syntax, usage and applications of PHP and MySQL.

Uploaded by

pzeel710
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
311 views

PHP & MySQL Question Bank

This document contains a list of 59 multiple choice questions about PHP and MySQL. It covers topics like PHP variables, arrays, functions, operators, and MySQL commands. The questions are related to syntax, usage and applications of PHP and MySQL.

Uploaded by

pzeel710
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

501 PHP and MySQL MCQ

1. What is the full form of WAMP?


Windows Application MySQL and PHP
Windows Apache MySQL and PHP
Windows Apache MySQL and Perl
None of these

2. Who is known as the father of PHP?


Drek Kolkevi
List Barely
Rasmus Lerdrof
None of the above

3. Variable name in PHP starts with -


! (Exclamation)
$ (Dollar)
& (Ampersand)
# (Hash)

4. Which of the following is not a variable scope in PHP?


Extern
Local
Static
Global

5. Which of the following is used to display the output in PHP?


echo
write
print
Both echo and print

6. Which of the following is used for concatenation in PHP?


+ (plus)
* (Asterisk)
. (dot)
append()

7. Which of the following is the use of strpos() function in PHP?


The strpos() function is used to search for the spaces in a string
The strpos() function is used to search for a number in a string
The strpos() function is used to search for a character/text in a string
The strpos() function is used to search for a capitalize character in a string

Page 1
8. Which of the following is the correct way to create a function in PHP?
Create myFunction()
New_function myFunction()
function myFunction()
None of the above

9. Which of the following is the correct use of the strcmp() function in PHP?
The strcmp() function is used to compare the strings excluding case
The strcmp() function is used to compare the uppercase strings
The strcmp() function is used to compare the lowercase strings
The strcmp() function is used to compare the strings including case

10. What is the use of isset() function in PHP?


The isset() function is used to check whether variable is set or not
The isset() function is used to check whether the variable is free or not
The isset() function is used to check whether the variable is string or not
None of the above

11. Which of the following function displays the information about PHP and its configuration?
php_info()
phpinfo()
info()
None of the above

12. Which of the following function is used to set cookie in PHP?


createcookie()
makecookie()
setcookie()
None of the above

13. Which of the following function is used to unset a variable in PHP?


delete()
unset()
unlink()
None of the above

14. Which of the following is/are the code editors in PHP?


Notepad++
Notepad
Adobe Dreamweaver
All of the above

15. String values in PHP must be enclosed within -


Double Quotes

Page 2
Single Quotes
Both Single and Double Quotes
None of the above

16. Which of the following variable name is invalid?


$newVar
$new_Var
$new-var
All of the above

17. Which of the following is the correct way to create an array in PHP?
$season = array["summer" , "winter" , "spring" , "autumn"];
$season = array("summer" , "winter" , "spring" , "autumn");
$season = "summer" , "winter" , "spring" , "autumn";
All of the above

18. Echo returns 1 on success whereas print does not return any value.
True
False

19. Predict the output of the following piece of code.


$g = 40;
Echo “\$g=”.($g>>1);

$g=80
$g=160
$g=20
$g=10

20. The ____________ terminates the remaining iteration of the loop whereas ____________
statement terminates the current iteration of the loop.
Break, continue
For, foreach
While, do…while
Continue, break

21. Pick the odd one out.


current()
next()
list()
prev()

22. Which of the following is not a super global array?


$_POST

Page 3
$_COOKIE
$_REQUEST
None of these

23. What will be the output of the following code?


$s="Let your dreams be bigger than your fears";
echo "Position:".strrpos($s,"your");

Position:4
Position:30
Position:31
Position:5

24. What will be the output of the following code?


echo ceil(129.5)."::".floor(129.5)."::".round(129.5);

129::129::129
130::130::130
129::130::129
130::129::130

25. Which of the following function by default returns the current time measured in the number
of seconds since January 1 1970 00:00:00?
date()
time()
mktime()
curtime()

26. With respect to variable number of arguments in UDF, which of the following function
returns the number of arguments passed during function call?
func_num_args()
func_get_arg()
func_get_args()
func_get_argv()

27. The ____________ is a persistent user state management technique, whereas


_______________ is non-persistent user state management technique.
Cookie, Session
Session, Cookie
Cookie, Query String
Query String, Session

28. Which function needs to be called whenever we want to set or get the value of session
variables?

Page 4
start_session()
session_start()
mysql_session_start()
$_SESSION()

29. Which of the following function is used for both; setting the cookie variables as well as to
destroy session variables?
$_COOKIE[]
$_COOKIE()
Unset()
Setcookie()

30. The _____________ function is used to destroy all session variables.


session_unregister()
unset()
session_destroys()
session_destroy()

31. The _____________ super global array is used to retrieve the properties of the file which you
have selected using file control.
$_FILE
$_FILES
$_REQUEST
$_POST

32. Which tag is used to import the jQuery library file in the code?
<head>
<script>
<import>
<style>

33. Which selector expression will hide all the elements having class cute?
$(.cute).hide();
$(“.cute”).hide();
$(“#cute”).hide();
$(“.cute”).hides();

34. Pick the odd one out.


fadeIn()
fadeOut()
show()
fadeTo()

35. Which of the following jQuery method is used to sets or gets the value of form control?

Page 5
html()
text()
value()
val()

36. The ____________ method removes the child elements from the selected element whereas
the ______________ method removes the selected element and its child elements.
empty() and remove()
remove() and empty()
delete() and remove()
remove() and delete()

37. Which of the following does not belongs to sibling method of a jQuery?
children()
siblings()
next()
prev()

38. The ________________ function sends a unique query to the currently active database in
order execute it.
mysqli_query()
mysqli_fetch_array()
mysqli_execute()
mysqli_select_db()

39. The ____________ storage engine supports FOREIGN KEY referential integrity constraints.
ISAM
MyISAM
InnoDB
Merge

40. Which of the following is not a server-side scripting language?


PHP
ASP
Java Script
Python

41. Following are the advantages of some scripting languages. (i) Code remain hidden from the
user. (ii) It is browser independent. According to your opinion, it’s a ________ scripting
language.
Client-Side
Server-Side

42. Which of the following is not a feature of PHP?

Page 6
Open Source
Suitability
Flexibility
Embedded with HTML

43. PHP Programmer can write the PHP code in which tags?
Canonical Tag <?php //Code ?>
Short Tag <? //Code ?>
ASP Tag <% Code %>
All of the above

44. Which of the following is a composite PHP data-type?


Integer
Boolean
Array
String

45. String within single quote is parsed whereas string within double quote is not parsed.
True
False
May be

46. Array with alpha-numeric index in PHP is known as _____________


Indexed Array
String Array
Access Array
Associative Array

47. Which PHP built-in function will help you to create constants?
Const()
Constant()
Define()
Include()

48. Predict the output of the following piece of code.


$p=90;
$q=90.0;
var_dump($p===$q);

bool(false)
bool(true)
1
0

Page 7
49. In PHP, the _______ is an error control operator whereas ________ is a string concatenation
and assignment operator.
.= , .
``,@
@, .=
.=, @

50. Which of the following function/functions are used to print message and exit from the current
php script?
Die()
Exit()
Break()
Both exit() and die()

51. If you want to check-out that particular element is present in array or not. You will use which
PHP built-in function?
Is_array()
In_array()
Present_array()
Is_found()

52. Which sorting method is used if we want to sort elements of an array in ascending order by
preserving it key-value association?
sort()
ksort()
arsort()
asort()

53. I have declare a variable like; $asan=”Chakrasan”; Which of the following line will display
an output - She is doing Chakrasan?
Echo ‘She is doing $asan’;
Echo “She is doing $Asan“;
Echo “She is doing $asan“;
All of these

54. I want to create a constant named COLLEGE with value “BCA”. Which line of code will
help me?
const(‘COLLEGE’, ‘BCA’)
Constant(‘COLLEGE’, ‘BCA’)
Define(‘COLLEGE’, ‘BCA’)
Include(‘COLLEGE’, ‘BCA’)
None of these

Page 8
55. I want to compare two values at the same time I am also looking forward that the data type of
these values must also be same. Which operator I should use?
=
==
===
strcasecmp( )

56. Which sorting method is used if we want to sort elements of an array in descending order of
their key at the same time preserving it key-value association?
kdsort()
ksort()
krsort()
assort()
rsort()

57. We can execute PHP scripts on Windows as well as Linux based platform. Which feature
state so?
Open source
Cost
Strong user community
Cross platform compatibility
Stability

58. I have declare a variable like; $n = 100; What will be the output of the commands echo
$n<<2; and echo $n>>2 respectively?
200 50
400 25
50 200
25 400

59. I have defined an array storing marks of the student with its associated subject name. I am
interested in fetching both key and value of this array. Which of the following construct
should I use?
While
For
Foreach
Switch

60. I am writing a program to check input number is prime or not. As soon as I came to know
that a number is divisible indicating a number is not prime, I want to come out of the loop.
Which of the following statement I have to use?
break
continue
die

Page 9
exit

61. Assume that you have defined one array storing anything and you want to access the last
element of the array. Which function you will adopt?
current()
next()
prev()
end()

62. When we use form method _______, then form data are visible in the URL.
get
post
request
All of these
None of these

63. I want to take an input of joining date of an employee and want to assign “doj“ as its name
property. I also want to apply a restriction that user can’t leave this field empty. Suggest me
appropriate HEML code.
<input type="date" name="doj" required />
<input type="doj" name="date" required />
<input type="date" name="doj" />
<input type="text" name="doj" required />

64. Assume that you have designed a form having post method. Which amongst the following
array will store the form data for processing?
$_GET
$_POST
$_REQUEST
Both $_POST and $_REQUEST

65. Which of the following function(s) can be used to compare two strings by ignoring their
case?
strcmp()
compare()
strcasecmp()
All of these

66. I have a number 34.0054 in a variable $x. I want to round up the value 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?
$y = abs($x);
$y = ceil($x)
$y = floor($x)

Page 10
$y = round($x)

67. Which of the following date function can be used to make sure a particular date is a valid
date or not by providing month, day and year respectively?
date()
detdate()
setdate()
checkdate()

68. I have designed a form having one submit button and the name 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?
if ( present ($_REQUEST[‘save’]) )
if (isset $_REQUEST[‘save’] )
if ( isset ($_Request[‘save’]) )
if ( isset ($_REQUEST[‘save’]) )

69. Which of the following meta character can be used in regular expression of the ereg( )
that indicates that there should be zero or one occurrence of the preceding character or
expression?
*
+
?
^

70. Which of the following function can be used to redirect from one page to another page
unconditionally?
include()
location()
header()
implode()

71. If we want to preserve the values of local variables that we have defined inside the
function body for the next function call, we can do it with the help of __________
keyword.
global
static
function
none of these

72. Sapna is a PHP programmer and she has stored the product id ‘P1254’ 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?
setcookie(“ck_pid”, $pid, 7 * 24 * 60 * 60);

Page 11
setcookie(“ck_pid”, $pid, time() + 7 * 24 * 60 * 60);
setcookie(“ck_pid”, $pid,);
setcookie(“ck_pid”, $pid, time() - 7 * 24 * 60 * 60);

73. We can retrieve the values of query string variables using _________ array.
Only $_GET
Only $_POST
Only $_REQUEST
Both $_GET and $_REQUEST

74. PHP provides the ____________ in-built function to upload file to different location
other then temporary location.
move_upload_file()
upload_move_file()
move_uploaded_file()
uploaded_move_file()

75. Assume Event table in some database having some records. Which SQL command you
can use if you want to change the value of Event_Time field of this table?
INSERT
ADD
UPDATE
ALTER

76. Suppose you have designed a database name “db_Quiz”. Which of the following line of
code is used to select this database in the PHP application? Assume that connection
resource is stored in $con variable.
mysqli_db_select($con, db_Quiz)
mysqli_db_select($con, “db_Quiz”)
mysqli_select_db($con, db_Quiz)
mysqli_select_db($con, “db_Quiz”)

77. Which of the following is not a jQuery event?


click()
onClick()
blur()
mouseleave()

78. While establishing connection of PHP with MySQL using mysqli_connect() function, we
need to provide name of the MySQL user. What is the default name of the MySQL user?
localhost
mysql
root

Page 12
mysqli

79. What CSV stands for?


Common Separated Value
Command Separated Value
Comma Separated Value
Comma Standard Value

80. Which of the following selector expression will select the element having id “hdng”?
$(#hdng)
$(‘#hdng’)
$(‘.hdng’)
$(hdng)

81. Which of the following method does not provides sliding effect?
slideUp()
slideDown()
fadeIn()
slideToggle()

82. I have a dropdown menu in my form having class property “city”. What line of jQuery
code should I write if I want to get the value of that menu? Consider that I want to store
that value in a variable named “vcity”.
$vcity = $(‘.city’).val();
var vcity = $(‘.city’).val();
var vcity = $(‘.city’).text();
var vcity = $(‘.city’).html();

83. Suppose you want to execute SELECT query that you have stored in a variable $q, and
the connection is stored in $con resource variable. You want to store the address of this
query’s result in a variable name $result. Which of the following line you should write to
do this job?
$res = mysqli_query($con, $q);
$result = mysqli_query($con, $q);
$result = mysqli_query($q);
$result = mysqli_fetch_array($con, $q);

84. Which of the following function will help you, if you want to get the number of rows
present in the result set of SELECT query?
mysqli_fetch_row()
mysqli_num_row()
mysqli_num_rows()
None of these

Page 13
85. Which of the following function will fetches a result row as an associative array, a
numeric array, or both.
mysqli_fetch_array()
mysqli_fetch_row()
mysqli_fetch_assoc()
mysqli_result()

86. Which of the following jQuery method is used to add as well as remove remove one or
more CSS class from the selected element?
addClass()
removeClass()
toggleClass()
ToggleClass()

87. Which of the following form method of the form element is suggested to use when we want
to pass sensitive information?
POST
GET

88. Which of the following function(s) is/are used to count total number of elements in an array?
Count
Sizeof
Array_count
Both count and sizeof

89. Which of the following function is used to add the content of some other file in the current
script?
Require( )
Include( )
Include_once( )
All of the above

90. Does PHP support the concept of conditional function?


Yes
No

91. What will be the output of the following PHP code?


echo chr(90);
a
z (lower)
Z (upper)
Y

92. What will be the output of the following PHP code?

Page 14
echo "<br>".sqrt(100)."::".pow(10,2);

100::10
100::100
10:100
None of the above

93. We can use ___ to comment a single line in PHP code?


i) /?
ii) //
iii) #
iv) /* */

Only ii)
i), iii) and iv)
ii), iii) and iv)
Both ii) and iv)

94. Which of the following php statement/statements will store 111 in variable num?
i) int $num = 111;
ii) int num = 111;
iii) $num = 111;
iv) 111 = $num;

Both i) and ii)


All of the mentioned.
Only iii)
Only i)

95. Which of the following jQuery filtering method returns all elements that do not match the
criteria?
first( )
last( )
filter( )
not( )

96. The __________ traversing method of jQuery returns all ancestor elements of the selected
element, all the way up to the document's root element.
parent( )
parents()
parentsUntil()

97. Which of the following jQuery method is used to sets or get one or more style properties for
the selected elements?

Page 15
html( )
css()
val()
addCSS()

98. Which of the following is a built-in function in PHP that adds a value to the end of an array?
array_push()
inend_array()
into_array()
None of the above

99. Which of the following function converts a string to all uppercase?


upper()
uppercase()
struppercase()
strtoupper()

100. The function in PHP that can be used to concatenate array elements to form a single
delimited string is -
implode()
concat()
explode()
concatenate()

Page 16

You might also like