Explore topic-wise MCQs in Php.

This section includes 42 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

([w-]+) will match ___________

A. ne word characters
B. ne or more word characters
C. ne or more word characters and/or hypens
D. ne or more word characters and hypens
Answer» D. ne or more word characters and hypens
2.

What does the DESC keyword do in the following query?SELECT *FROM MY_TABLEWHERE ID > 0ORDER BY ID, NAME DESC"

A. t causes the dataset returned by the query to be sorted in descending order
B. t causes rows with the same ID to be sorted by NAME in ascending order
C. t causes rows with the same ID to be sorted by NAME in descending order
D. t causes rows to be sorted by NAME first and then by ID
E. t causes the result set to include a description of the NAME field
Answer» D. t causes rows to be sorted by NAME first and then by ID
3.

Which of the following is not an SQL aggregate function?

A. VG
B. UM
C. IN
D. AX
E. URRENT_DATE()
Answer» F.
4.

SQL is not case sensitive. SELECT is the same as select.

A. rue
B. alse
Answer» B. alse
5.

Transactions are used to treat sets of SQL statements atomically.

A. rue
B. alse
Answer» B. alse
6.

In PHP in order to access MySQL database you will use:

A. ysqlconnect() function
B. ysql-connect() function
C. ysql_connect() function
D. ql_connect() function
Answer» D. ql_connect() function
7.

Can joins be nested?

A. rue
B. alse
Answer» B. alse
8.

Use the .............. to delete the data inside the table, and not the table itself?

A. ROP TABLE
B. ELETE TABLE
C. RUNCATE TABLE
D. EMOVE TABLE
Answer» D. EMOVE TABLE
9.

What will happen at the end of the following sequence of SQL commands?BEGIN TRANSACTIONDELETE FROM MYTABLE WHERE ID=1DELETE FROM OTHERTABLEROLLBACK TRANSACTION

A. he contents of OTHERTABLE will be deleted
B. he contents of both OTHERTABLE and MYTABLE will be deleted
C. he contents of OTHERTABLE will be deleted, as will be all the contents of MYTABLE whose ID is 1
D. he database will remain unchanged to all users except the one that executes these queries.
E. he database will remain unchanged
Answer» F.
10.

The ............. statement is used to delete a table.

A. ROP TABLE
B. ELETE TABLE
C. EL TABLE
D. EMOVE TABLE
Answer» B. ELETE TABLE
11.

Use the .............. to delete the data inside the table, and not the table itself?%!

A. DROP TABLE
B. DELETE TABLE
C. TRUNCATE TABLE
D. REMOVE TABLE
Answer» B. DELETE TABLE
12.

What will happen at the end of the following sequence of SQL commands?BEGIN TRANSACTIONDELETE FROM MYTABLE WHERE ID=1DELETE FROM OTHERTABLEROLLBACK TRANSACTION%!

A. The contents of OTHERTABLE will be deleted
B. The contents of both OTHERTABLE and MYTABLE will be deleted
C. The contents of OTHERTABLE will be deleted, as will be all the contents of MYTABLE whose ID is 1
D. The database will remain unchanged to all users except the one that executes these queries.
E. The database will remain unchanged
Answer» D. The database will remain unchanged to all users except the one that executes these queries.
13.

What does the DESC keyword do in the following query?SELECT *FROM MY_TABLEWHERE ID > 0ORDER BY ID, NAME DESC"%!

A. It causes the dataset returned by the query to be sorted in descending order
B. It causes rows with the same ID to be sorted by NAME in ascending order
C. It causes rows with the same ID to be sorted by NAME in descending order
D. It causes rows to be sorted by NAME first and then by ID
E. It causes the result set to include a description of the NAME field
Answer» D. It causes rows to be sorted by NAME first and then by ID
14.

Which of the following is not an SQL aggregate function?%!

A. AVG
B. SUM
C. MIN
D. MAX
E. CURRENT_DATE()
Answer» F.
15.

SQL is not case sensitive. SELECT is the same as select.%!

A. True
B. False
Answer» B. False
16.

Transactions are used to treat sets of SQL statements atomically.%!

A. True
B. False
Answer» B. False
17.

In PHP in order to access MySQL database you will use:%!

A. mysqlconnect() function
B. mysql-connect() function
C. mysql_connect() function
D. sql_connect() function
Answer» D. sql_connect() function
18.

*$_([w-]+) will match ___________?

A. one word characters
B. one or more word characters
C. one or more word characters and/or hypens
D. one or more word characters and hypens
Answer» D. one or more word characters and hypens
19.

*$_Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query??

A. num_rows()
B. affected_rows()
C. changed_rows()
D. new_rows()
Answer» C. changed_rows()
20.

*$_Which method rolls back the present transaction??

A. commit()
B. undo()
C. back()
D. rollback()
Answer» E.
21.

*$_If there is no error, then what will the error() method return??

A. TRUE
B. FALSE
C. Empty String
D. 0
Answer» D. 0
22.

*/*_Which one of the following statements is used to create a table??

A. CREATE TABLE table_name (column_name column_type);
B. CREATE table_name (column_type column_name);
C. CREATE table_name (column_name column_type);
D. CREATE TABLE table_name (column_type column_name);
Answer» B. CREATE table_name (column_type column_name);
23.

%_The (|/) tells the server to match ____________%

A. nothing
B. forward slash
C. backward slash
D. either nothing or a forward slash
Answer» E.
24.

%_Which of the methods are used to manage result sets using both associative and indexed arrays?_%

A. get_array() and get_row()
B. get_array() and get_column()
C. fetch_array() and fetch_row()
D. fetch_array() and fetch_column()
Answer» D. fetch_array() and fetch_column()
25.

%_Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?_%

A. get_row()
B. fetch_row()
C. fetch()
D. row()
Answer» D. row()
26.

%_Which method returns the error code generated from the execution of the last MySQL function?_%

A. errno()
B. errnumber()
C. errorno()
D. errornumber()
Answer» B. errnumber()
27.

_ In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?$?

A. PHP 5.0
B. PHP 5.1
C. PHP 5.2
D. PHP 5.3
Answer» E.
28.

_The URLs in the administrative links won’t mean anything to admin.php unless you modify _________$?

A. .htaccess
B. .adminaccess
C. .htmlaccess
D. .urlaccess
Answer» B. .adminaccess
29.

_Which one of the following methods recuperates any memory consumed by a result set?$?

A. destroy()
B. remover()
C. alloc()
D. free()
Answer» E.
30.

_Which one of the following methods is used to recuperating prepared statements resources?$?

A. end()
B. finish()
C. final()
D. close()
Answer» E.
31.

_Which one of the following methods can be used to diagnose and display information about a MySQL connection error?$?

A. connect_errno()
B. connect_error()
C. mysqli_connect_errno()
D. mysqli_connect_error()
Answer» D. mysqli_connect_error()
32.

Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?$?

A. extension=php_mysqli.dll
B. extension=mysql.dll
C. extension=php_mysqli.dl
D. extension=mysqli.dl
Answer» B. extension=mysql.dll
33.

Once your application can generate administrative links, you need to load those links into _________?

A. php.ini
B. index.ini
C. index.php
D. start.php
Answer» D. start.php
34.

Which one of the following methods is responsible for sending the query to the database??

A. query()
B. send_query()
C. sendquery()
D. query_send()
Answer» B. send_query()
35.

Which of the following methods is used to execute the statement after the parameters have been bound??

A. bind_param()
B. bind_result()
C. bound_param()
D. bound_result()
Answer» B. bind_result()
36.

Which one of the following statements can be used to select the database??

A. $mysqli=select_db(‘databasename’);
B. mysqli=select_db(‘databasename’);
C. mysqli->select_db(‘databasename’);
D. $mysqli->select_db(‘databasename’);
Answer» E.
37.

The updated MySQL extension released with PHP 5 is typically referred to as.

A. MySQL
B. mysql
C. mysqli
D. mysqly
Answer» D. mysqly
38.

When you are building administrative links you’ll need to accept two arguments, which of the following are they?$

A. URL of previous entry and URL of the entry you are working with
B. The current page and previous page
C. URL of previous entry and previous page
D. The current page and URL of the entry you are working with
Answer» E.
39.

Which of the following DBMSs do not have a native PHP extension?

A. MySQL
B. IBM DB/2
C. PostgreSQL
D. Microsoft SQL Server
E. None of the above
Answer» F.
40.

When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a function which removes the entry from the __________#

A. index.php
B. function.inc.php
C. database
D. admin.php
Answer» D. admin.php
41.

To identify entries marked for deletion, you check whether $_GET[‘page’] == ‘delete’ inside __________$

A. index.php
B. index.ini
C. admin.php
D. .htaccess
Answer» D. .htaccess
42.

You need to check whether ______ is set, to determine whether you’re editing an entry or creating a new one.$

A. $_GET[‘url’].
B. $_SET[‘url’].
C. $_GET[‘admin’].
D. $_SET[‘admin’].
Answer» B. $_SET[‚Äö√Ñ√≤url‚Äö√Ñ√¥].