You're creating a PHP script that should generate a list of all JPEG images in a specific directory. Which combination of PHP functions can achieve this?

  • opendir(), readdir(), and substr()
  • scandir(), file_get_contents(), and explode()
  • glob() and file_get_contents()
  • fopen() and fwrite()
To generate a list of JPEG images in a directory, you can use the opendir() and readdir() functions to iterate through files, and substr() to check file extensions. These functions are ideal for this task.

To move an uploaded file to a new location, PHP provides the ________ function.

  • move_uploaded_file()
  • rename()
  • copy()
  • unlink()
PHP provides the move_uploaded_file() function specifically for moving uploaded files to a new location, ensuring security and proper handling.

Superglobals in PHP are ________ arrays, meaning they can be accessed regardless of the scope.

  • associative
  • multidimensional
  • indexed
  • one-dimensional
Superglobals in PHP, like $_POST and $_GET, are associative arrays. They can be accessed globally and are pre-defined by PHP, making them accessible everywhere.

When using MySQLi in PHP, which function is used to prepare an SQL statement for execution?

  • mysqli_query
  • mysqli_prepare
  • mysqli_execute
  • mysqli_fetch
In MySQLi, the 'mysqli_prepare' function is used to prepare an SQL statement for execution. Prepared statements enhance security and performance.

What does PDO stand for in the context of PHP?

  • PHP Data Object
  • Public Data Object
  • PHP Database Object
  • PHP Data Operator
PDO stands for "PHP Data Object." It's a PHP extension that provides a consistent, database-agnostic interface for interacting with databases.

To merge two or more arrays into a single array, you would use the ________ function in PHP.

  • mergeArrays()
  • array_combine()
  • array_merge()
  • combineArrays()
In PHP, the array_merge() function is used to merge two or more arrays into a single array. This is a common operation when working with arrays in PHP, allowing you to combine data efficiently.

Which keyword is used in PHP to handle exceptions?

  • throw
  • try
  • catch
  • finally
In PHP, the catch keyword is used to handle exceptions. It is used to catch and manage exceptions that are thrown in the try block.

What type of network is best suited for connecting devices in a single building or floor?

  • LAN
  • WAN
  • PAN
  • MAN
LAN (Local Area Network) is a network type that is designed to operate over a small physical area such as an office, building, or a group of buildings. It allows devices to connect and communicate within a localized environment.

Which PHP function is used to set a cookie?

  • setCookie()
  • createCookie()
  • sendCookie()
  • cookie()
The correct function is setCookie(). It is used in PHP to set cookies on the client's browser. Cookies are often used for tracking user preferences or maintaining session data.

What is the primary advantage of using prepared statements in PHP?

  • Improved code readability
  • Enhanced code reuse
  • Better performance
  • Protection against SQL injection
The primary advantage of using prepared statements in PHP is protection against SQL injection. They separate SQL code from user data, preventing malicious attacks.