R4RIN
Articles
Java 8
MCQS
PHP MCQ Quiz Hub
PHP Mcq Set 4
Choose a topic to test your knowledge and improve your PHP skills
1. Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
extension=php_mysqli.dll
extension=mysql.dll
extension=php_mysqli.dl
extension=mysqli.dl
2. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
PHP 5.0
PHP 5.1
PHP 5.2
PHP 5.3
3. Which one of the following statements is used to create a table?
CREATE TABLE table_name (column_name column_type);
CREATE table_name (column_type column_name)
CREATE table_name (column_name column_type);
CREATE TABLE table_name (column_type column_name);
4. Which one of the following statements instantiates the mysqli class?
mysqli = new mysqli()
$mysqli = new mysqli()
$mysqli->new.mysqli()
mysqli->new.mysqli()
5. Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
connect_errno()
connect_error()
mysqli_connect_errno()
mysqli_connect_error()
6. Which method returns the error code generated from the execution of the last MySQL function?
errno()
errnumber()
errorno()
errornumber()
7. If there is no error, then what will the error() method return?
TRUE
FALSE
Empty String
0
8. Which one of the following statements should be used to include a file?
#include ‘filename’;
include ‘filename’;
@include ‘filename’;
#include <filename>;
9. Which one of the following methods is responsible for sending the query to the database?
query()
send_query()
sendquery()
mysqli_query()
10. Which one of the following methods recuperates any memory consumed by a result set?
destroy()
mysqli_free_result()
alloc()
free()
11. Which of the methods are used to manage result sets using both associative and indexed arrays?
get_array() and get_row()
get_array() and get_column()
fetch_array() and fetch_row()
mysqli_fetch_array() and mysqli_fetch_row()
12. Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
num_rows()
affected_rows()
changed_rows()
mysqli_affected_rows()
13. Which version of MySQL introduced the prepared statements?
MySQL 4.0
MySQL 4.1
MySQL 4.2
MySQL 4.3
14. Which of the following methods is used to execute the statement after the parameters have been bound?
bind_param()
bind_result()
bound_param()
bound_result()
15. Which one of the following methods is used to recuperating prepared statements resources?
end()
finish()
mysqli_close()
close()
16. Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
get_row()
fetch_row()
fetch()
mysqli_fetch_row()
17. Which method rolls back the present transaction?
commit()
undo()
mysqli_rollback()
rollback()
18. Which one of the following is not a valid class name?
ShopProduct
Shopproduct
Shopproduct1
1shopproduct
19. Fill in the blank with the best option. An Object is a/an ________ of a class.
type
prototype
instance
object
20. Which version of PHP introduced the visibility keywords i.e public, private, and protected?
PHP 4
PHP 5
PHP 5.1
PHP 5.3
21. Which characters is used to access property variables on an object-by-object basis?
::
=
->
.
22. Code that uses a class, function, or method is often described as the ____
client code
user code
object code
class code
23. Which keyword precedes a method name?
method
function
public
protected
24. If you omit the visibility keyword in your method declaration, by default the method will be declared as _____
public
private
protected
friendly
25. Which function is used to determine whether the variables value is either TRUE or FALSE?
boolean()
is_boolean()
bool()
is_bool()
26. Which version of PHP introduced class type hints?
PHP 4
PHP 4.3
PHP 5
PHP 5.3
27. Inheritance is the means by which one or more classes can be derived from a/an ___________ class.
base
abstract
null
predefined
28. What should be used to refer to a method in the context of a class rather than an object you use?
>
__
$
::
29. Prior to which version of PHP did constructors took the name of the enclosing class.
PHP 4
PHP 5
PHP 5.3
PHP 5.4
30. Which method or property can only be accessed from within the enclosing class? Even subclasses have no access.
public
friendly
private
protected
31. A mutator method is also called as ___________
Setter
Accessor
Getter
Destructor
32. PHP stands for -
Hypertext Preprocessor
Pretext Hypertext Preprocessor
Personal Home Processor
None of the above
33. Who is known as the father of PHP?
Drek Kolkevi
list Barely
Rasmus Lerdrof
None of the above
34. Variable name in PHP starts with -
! (Exclamation)
$ (Dollar)
& (Ampersand)
# (Hash)
35. Which of the following is the default file extension of PHP?
.php
.hphp
.xml
.html
36. Which of the following is not a variable scope in PHP?
Extern
Local
Static
Global
37. Which of the following is correct to add a comment in php?
& .... &
// ....
/* .... */
Both (b) and (c)
38. Which of the following is used to display the output in PHP?
echo
write
print
Both (a) and (c)
39. Which of the following is the use of strlen() function in PHP?
The strlen() function returns the type of string
The strlen() function returns the length of string
The strlen() function returns the value of string
The strlen() function returns both value and type of string
40. 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
append()
41. Which of the following starts with __ (double underscore) in PHP?
Inbuilt constants
User-defined constants
Magic constants
Default constants
42. 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
43. What does PEAR stands for?
PHP extension and application repository
PHP enhancement and application reduce
PHP event and application repository
None of the above
44. Which of the following PHP function is used to generate unique id?
id()
mdid()
uniqueid()
None of the above
45. Which of the following is the correct way of defining a variable in PHP?
$variable name = value;
$variable_name = value;
$variable_name = value
$variable name as value;
46. 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
47. What is the use of fopen() function in PHP?
The fopen() function is used to open folders in PHP
The fopen() function is used to open remote server
The fopen() function is used to open files in PHP
None of the above
48. 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
49. What is the use of sprintf() function in PHP?
The sprintf() function is used to print the output of program
The sprintf() function is used to send output to variable
Both of the above
None of the above
Submit