To ensure an uploaded file is not malicious, one should validate the file's ________ before saving it.

  • File extension
  • File size
  • File name
  • MIME type
The correct option is "MIME type." This is crucial because a file's MIME type provides information about its content, allowing you to verify that the uploaded file matches its claimed type and is not malicious.

What is the primary difference between "overloading" and "overriding" in PHP OOP?

  • Overloading is used to create multiple methods with the same name but different parameters.
  • Overriding is used to create multiple methods with the same name but different parameters.
  • Overloading allows you to define a new class that inherits from an existing class.
  • Overriding allows you to create a new class that inherits from an existing class.
Overloading is about using the same method name with different parameters within the same class, while overriding is about providing a new implementation of a method in a child class.

Why is it recommended to avoid using the @ error suppression operator in PHP?

  • It enhances code readability
  • It prevents the error from occurring
  • It improves error handling
  • It makes code execute faster
The '@' operator suppresses error messages, making it hard to diagnose issues. It's best to handle errors explicitly for better debugging and code quality.

PHP provides a function named ________ to get the current date and time.

  • current_datetime()
  • time_now()
  • date_time_now()
  • date()
PHP's date() function is used to get the current date and time. It allows you to format the date and time in various ways as per your requirements.

Which type of JOIN returns only the rows where there is a match in both tables?

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN
An INNER JOIN returns only the rows where there is a match in both tables. It combines records from two tables based on a common column and includes only the rows with matching values in both tables. Rows with no matching values are excluded from the result set.

Imagine you're building a feedback form where users can submit comments. To prevent potential script injections, which PHP function would you use to process the comment text before displaying it back to other users or saving it to a database?

  • htmlentities()
  • urlencode()
  • strip_tags()
  • base64_encode()
The htmlentities() function is used to convert potentially harmful characters in user input to their HTML entities, preventing script injections. It's a security measure to sanitize user-generated content.

Which of the following SQL statements is used to start a transaction in a relational database?

  • BEGIN TRANSACTION
  • INITIATE TRANSACTION
  • START TRANSACTION
  • CREATE TRANSACTION
The correct SQL statement to begin a transaction in a relational database is "BEGIN TRANSACTION." Starting a transaction is essential for ensuring data consistency.

You are developing a PHP script where you need to ensure that a particular value, say the company name, remains unchanged throughout the script. Which of the following would be the best approach?

  • Define a constant
  • Use a global variable
  • Pass the value as a function parameter
  • Store the value in a session variable
Defining a constant in PHP ensures that the value remains unchanged throughout the script, providing a read-only variable. This is suitable for constant values like company names.

A ___________ typically connects personal devices within an individual's immediate vicinity, such as connecting a smartphone to a laptop via Bluetooth.

  • WAN
  • LAN
  • PAN
  • MAN
PAN (Personal Area Network) is a network for personal devices and is typically used for connections within an individual's immediate vicinity, often within the range of a single person. Examples include connecting a smartphone to a laptop via Bluetooth or connecting a smartwatch to a phone.

Which HTTP method appends form-data into the URL in name/value pairs?

  • GET
  • POST
  • PUT
  • DELETE
The GET method appends form data into the URL as name/value pairs. This makes the data visible in the URL, which is suitable for non-sensitive information.

In a multidimensional array, the ________ function can be used to count the total number of elements.

  • count
  • size
  • total_elements
  • array_length
To count the total number of elements in a multidimensional array, you can use the 'count' function in PHP. It counts all elements, including those within nested arrays.

Which PDO method is used to begin a transaction?

  • beginTransaction()
  • startTransaction()
  • openTransaction()
  • initiateTransaction()
The beginTransaction() method is used to initiate a transaction in PDO. Transactions are essential for maintaining data integrity when multiple database operations need to be atomic.