This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Working with Databases-1”.
1. Which one of the following databases has PHP supported almost since the beginning?
a) Oracle Database
2. The updated MySQL extension released with PHP 5 is typically referred to as..
Explanation: The updated MySQL extension with PHP 5 is known as MySQL and typically referred to as mysqli.
3. Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
Explanation: Also make sure that extension_dir directive points to the appropriate directory.
4. 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
Explanation: PHP required that MySQL client library be installed on the server from which PHP was communicating with MySQL, whether the MySQL server also happened to reside locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.
5. 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);
6. Which one of the following statements instantiates the mysqli class?
a) mysqli = new mysqli()
b) $mysqli = new mysqli()
Explanation: If you choose to interact with MySQL server using the object-oriented interface, you need to first instantiate the mysqli class via its constructor.
7.Which one of the following statements can be used to select the database?
8. Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
Explanation: The mysqli extension includes a few features that can be used to capture error messages or alternatively you can use exceptions.
9. Which method returns the error code generated from the execution of the last MySQL function?
Explanation: Error numbers are often used in lieu of natural-language message to ease software internationalization efforts and allow for customization of error messages.
10. If there is no error, then what will the error() method return?
c) Empty String
Sanfoundry Global Education & Learning Series – PHP Programming.
To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.