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.
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.
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.
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.
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.
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.
When processing multiple uploaded files in PHP, the $_FILES superglobal uses the format $_FILES['file']['property'][index], where 'property' can be ________ to get the type of the file.
- 'type'
- 'name'
- 'size'
- 'tmp_name'
The correct option is 'type.' When dealing with multiple uploaded files, accessing the 'type' property of the $_FILES array is essential for identifying the file type of each uploaded file. This is important for validation and processing.
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 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.
In PDO, the placeholders used in prepared statements can be either named or ________.
- Indexed
- Positional
- Indexed or Positional
- Named
In PDO, placeholders in prepared statements can be either named (e.g., :name) or positional (e.g., ?). Both are valid ways to bind values.
You have a long string containing multiple words and you need to extract each word as an individual item in an array. Which PHP function would be most suitable for this task?
- explode()
- implode()
- split()
- preg_split()
The explode() function in PHP is used to split a string into an array based on a specified delimiter. This is ideal for separating words in a long string into individual array items.
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.