Which function in PHP is used to make a connection to a MySQL database?

  • mysqli_query
  • mysql_connect
  • mysqli_connect
  • PDO::connect
The correct function is mysqli_connect. This function is used to establish a connection to a MySQL database in PHP using the MySQLi extension.

Which of the following SQL statements is used to retrieve data from a database?

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
The 'SELECT' statement is used to retrieve data from a database. It allows you to query and fetch specific data from one or more tables in a database.

What is the concept in OOP where a subclass can have methods with the same name as methods in its parent class?

  • Method Overloading
  • Method Hiding
  • Method Overriding
  • Method Inheritance
The concept in OOP where a subclass can have methods with the same name as methods in its parent class is called "Method Overriding." It allows a child class to provide a specific implementation of a method defined in the parent class.

The PDO attribute that controls the error reporting mode is named ________.

  • PDO::ERRMODE_SILENT
  • PDO::ERRMODE_WARNING
  • PDO::ERRMODE_EXCEPTION
  • PDO::ERRMODE_ERRMODE
The PDO attribute that controls the error reporting mode is named PDO::ERRMODE_EXCEPTION, which makes PDO throw exceptions for errors.

What is the main reason for hashing passwords before storing them in a database?

  • To make passwords case-insensitive
  • To save storage space
  • To improve password visibility
  • To enhance security
Hashing passwords before storing them in a database enhances security. It ensures that the original password is not stored, making it much more difficult for attackers to retrieve user passwords in case of a breach.

What does XSS stand for in the context of web security?

  • Cross-Site Scripting
  • Extra Security System
  • External System Security
  • Excess Server Stress
XSS (Cross-Site Scripting) is a security vulnerability where attackers inject malicious scripts into web pages viewed by other users, compromising their data and privacy.

When handling multiple select fields in a form, the name attribute should end with ________ to ensure all selected values are sent to the server.

  • '[]'
  • '*'
  • '+'
  • 'multiple'
To ensure all selected values are sent to the server, the name attribute should end with '[]' for multiple select fields. This tells PHP to treat the data as an array.

What will the strpos() function return if the substring is not found in the string?

  • -1
  • 0
  • FALSE
  • Null
The strpos() function in PHP returns -1 when the substring is not found in the string. It's important to check for -1 to determine if the substring is absent.

Which of the following is NOT a valid way to return multiple values from a PHP function?

  • Using an array
  • Using a class with multiple properties
  • Using a comma-separated string
  • Using multiple return statements
While using a comma-separated string is technically possible, it's not a good practice for returning multiple values. The other options are valid approaches for returning multiple values.

In PHP, you can refer to the current namespace using the ________ keyword.

  • namespace
  • use
  • this
  • self
In PHP, the namespace keyword is used to refer to the current namespace, allowing for organized and modular code structure in PHP applications.